diff options
author | Astatin <[email protected]> | 2024-08-09 21:19:36 +0900 |
---|---|---|
committer | Astatin <astatin@redacted> | 2024-08-09 21:19:36 +0900 |
commit | 9790dc65026c22f26ea6e247c5506b88f36691a4 (patch) | |
tree | 053bced30579170dbeff79946ebcd4c22470f050 | |
parent | bdd60c734a477fc76e4398d9367d7071326d64aa (diff) |
Turn off screen during initialization to be compatible with sameboy
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | bunny.gbasm | 4 | ||||
-rw-r--r-- | definitions.gbasm | 1 | ||||
-rw-r--r-- | init.gbasm | 30 | ||||
-rw-r--r-- | main.gbasm | 8 | ||||
-rw-r--r-- | tiles.gbasm | 2 |
6 files changed, 39 insertions, 12 deletions
@@ -9,5 +9,11 @@ build/main.rom: main.gbasm run: build/main.rom gb $< +sameboy: build/main.rom + sameboy build/main.rom + +gearboy: build/main.rom + gearboy build/main.rom + clean: rm -rf build diff --git a/bunny.gbasm b/bunny.gbasm index c6a06de..04d14a9 100644 --- a/bunny.gbasm +++ b/bunny.gbasm @@ -7,7 +7,7 @@ Initialize_Bunny: LD $reg_viewport_x, A LD A, $50 LD $mem_bunny_x_px, A - LD A, $50 + LD A, $48 LD $mem_bunny_y_px, A RET @@ -178,6 +178,7 @@ Display_Bunny: ; X position in $81, Y position in $80 LD A, B LD (HL+), A LD A, E + INC A LD (HL+), A LD A, D LD (HL+), A @@ -193,6 +194,7 @@ Display_Bunny: ; X position in $81, Y position in $80 LD (HL+), A LD A, E XOR $02 + INC A LD (HL+), A LD A, D LD (HL+), A diff --git a/definitions.gbasm b/definitions.gbasm index 8e9ea5b..fdefee8 100644 --- a/definitions.gbasm +++ b/definitions.gbasm @@ -1,5 +1,6 @@ .DEFINE reg_joypad ($00) .DEFINE reg_lcd_controller ($40) +.DEFINE reg_lcd_status ($41) .DEFINE reg_viewport_y ($42) .DEFINE reg_viewport_x ($43) .DEFINE reg_bg_palette ($47) @@ -5,7 +5,7 @@ VBlank: .PADTO 0x0100 Start: - JP =Empty_VRAM + JP =Initialize_RAM .PADTO 0x0104 Nintendo_Logo: ; The Nintendo logo must be stored in bytes 0x104-133 @@ -18,10 +18,29 @@ 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 +Initialize_RAM: +Empty_WRAM: + LD HL, $C000 + Empty_WRAM.loop: + XOR A + LD (HL+), a + LD a, $D0 + CP h + JR NZ, =Empty_WRAM.loop + +Wait_VBlank: + LD A, $reg_lcd_status + AND $03 + CP $01 + JR NZ, =Wait_VBlank + + ; LCDC + XOR A + LD $reg_lcd_controller, A + Empty_VRAM: ; (Clear screen) LD hl, $VRAM_start ; We set the HL register to the start of VRAM - -Empty_VRAM.loop: + Empty_VRAM.loop: XOR A LD (HL+), a ; We set the memory pointed to by HL to 0 and increase HL LD a, $a0 @@ -36,11 +55,6 @@ Empty_VRAM.loop: LD A, $e4 LD $reg_obj0_palette, A - ; LCDC - LD A, $reg_lcd_controller - OR $06 - LD $reg_lcd_controller, A - ; Interrupts LD A, $01 LD $reg_interrupt_enable, A @@ -3,9 +3,13 @@ Entrypoint: CALL =Load_Tile - CALL =Initialize_Bunny CALL =Load_Map - + CALL =Initialize_Bunny + + ; LCDC + LD A, $97 + LD $reg_lcd_controller, A + EI Wait_for_VRAM.loop: HALT diff --git a/tiles.gbasm b/tiles.gbasm index 4769e2a..bba72b9 100644 --- a/tiles.gbasm +++ b/tiles.gbasm @@ -62,7 +62,7 @@ memcpy: ; src = DE, dest = HL, n = BC RET Load_Tile: - LD HL, $8010 + LD HL, $8020 LD DE, =OBJ_Tile_Image_Data LD BC, $00c0 CALL =memcpy |