From 481301023e26fc919dd9f9206369ac485670728a Mon Sep 17 00:00:00 2001 From: bx Date: Tue, 31 Aug 2021 17:32:08 +0100 Subject: [PATCH] we now have lines! --- assembler.rb | 56 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/assembler.rb b/assembler.rb index 202487e..cde3e97 100644 --- a/assembler.rb +++ b/assembler.rb @@ -136,6 +136,11 @@ end + +def label + return $bytes.length + $base_addr +end + # this is a terrible idea and im doing it #$labels = {} #def method_missing(m, *args) @@ -148,6 +153,7 @@ end $base_addr = 0x80010000 # 0x10000 # 0x80010000 $file_size = 0x800 * 3 $gp0 = 0x1F801810 +$gp1 = 0x1F801814 # # # EXE HEADER # # # string "PS-X EXE" @@ -172,25 +178,49 @@ $bytes = [] # # # PROGRAM CODE # # # -nop ; jmp $base_addr + 16 ; nop ; word 0xdeadbeef +nop # ops should always be in format of # src [args] -> dest -lwi $gp0, 1 +# THIS IS NEEDED +lwi $gp1, t0 +lwi 0x03_00_00_00, t1 # display enable +sw t1, 0, t0 +lwi $gp0, t0 + +lwi 0xe1_000000 + 0b0_0_0_1_0_01_00_0_0000, t1 +sw t1, 0, t0 + +# THIS IS NEEDED +lwi 0xe4_000000 + (640) + (480 << 10), t1 # Drawing Area bottom right +sw t1, 0, t0 + +def line(st, en) + lwi 0x40_ffffff, t1 # monochrome line, color ffffff + sw t1, 0, t0 + + lwi st, t1 # line vert 1 + sw t1, 0, t0 + + lwi en, t1 # line vert 2 + sw t1, 0, t0 +end + +l_end_loop = label +line 0x0010_0010, 0x0030_0030 +line 0x0030_0030, 0x0060_0000 +line 0x0060_0000, 0x00f0_0060 + +nop ; nop ; nop ; nop +nop ; nop ; nop ; nop +nop ; nop ; nop ; nop +nop ; nop ; nop ; nop + +# l_end_loop = label nop - -lwi 0x10040, 2 - -sw 1, 0, 2 - -nop ; nop ; nop ; nop -nop ; nop ; nop ; nop -nop ; nop ; nop ; nop -nop ; nop ; nop ; nop - -jmp $base_addr +jmp l_end_loop nop