diff options
-rw-r--r-- | examples/minimal.gbasm | 2 | ||||
-rw-r--r-- | examples/serial.gbasm | 73 | ||||
-rw-r--r-- | examples/wave.gbasm (renamed from examples/zoom.gbasm) | 13 |
3 files changed, 86 insertions, 2 deletions
diff --git a/examples/minimal.gbasm b/examples/minimal.gbasm index 33405c3..4f51339 100644 --- a/examples/minimal.gbasm +++ b/examples/minimal.gbasm @@ -15,7 +15,7 @@ Checksum: ; The bytes 0x134-0x14d need to add up to 0xe7 (= 0xff - 0x19) Start: Wait_VBlank: - LD A, (0xFF00+$41) + LD A, ($41) AND $03 CP $01 JR NZ, =Wait_VBlank diff --git a/examples/serial.gbasm b/examples/serial.gbasm new file mode 100644 index 0000000..d4b4937 --- /dev/null +++ b/examples/serial.gbasm @@ -0,0 +1,73 @@ +; This ROM is a simple example of how to use serial connections. +; It will wait to receive text via the serial connection, save the text in memory until it encounters a new line (without overflow check), then send back in ASCII "Astatin" and a new line followed by the text that was received. + +.PADTO 0x0058 + JP =Serial_Recv + +.PADTO 0x0100 +Entry: + JP =Start + +.PADTO 0x0104 +Nintendo_Logo: ; The Nintendo logo must be stored in bytes 0x104-133 + .DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D + .DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 + .DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E + +.PADTO 0x0134 +Checksum: ; The bytes 0x134-0x14d need to add up to 0xe7 (= 0xff - 0x19) + .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 + .DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$e7 + +Start: + LD SP, $fffe + + LD A, $00 + LD ($40), A + + LD A, $08 + LD ($ff), A + + LD HL, $c000 + EI + + Lock: + HALT + EI + JR =Lock + +Serial_Recv: + LD A, ($01) + CP $0a + CALL Z, =Read_back + LD (HL+), A + RETI + +Read_back: + LD (HL), $00 + LD HL, =Astatin_ASCII + CALL =Print + LD HL, $c000 + CALL =Print + JP =Start + +Astatin_ASCII: +.DB $41, $73, $74, $61, $74, $69, $6e, $0a $00 + +Print: + .send_loop: + LD A, (HL+) + CP $00 + RET Z + + LD ($01), A + + LD A, $81 + + LD ($02), A + + .wait_transfer: + LD A, ($02) + BIT 7, A + JR NZ, =.wait_transfer + JR =.send_loop diff --git a/examples/zoom.gbasm b/examples/wave.gbasm index 6ed92a1..a63fc43 100644 --- a/examples/zoom.gbasm +++ b/examples/wave.gbasm @@ -22,6 +22,10 @@ Checksum: ; The bytes 0x134-0x14d need to add up to 0xe7 (= 0xff - 0x19) .DEFINE Wave_Top $c0 Start: + LD A, ($42) + LD ($82), A + LD A, ($43) + LD ($83), A LD C, $01 LD A, $03 LD ($FF), A @@ -41,7 +45,7 @@ Start: EI Halt_loop: HALT - JP Halt_loop + JP =Halt_loop Effect: LD A, ($44) @@ -64,7 +68,14 @@ Effect: RRCA SUB $02 + LD D, A + + LD A, ($83) + ADD D LD ($43), A + + LD A, ($82) + ADD D LD ($42), A RETI |