Game Boy ROM which displays sprites in emulators but not on real hardware
| ROM_HEADER: MACRO | |
| NINTENDO_LOGO | |
| DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; Cart name - 15bytes | |
| DB 0 ; $143 | |
| DB 0,0 ; $144 - Licensee code (not important) | |
| DB 0 ; $146 - SGB Support indicator | |
| DB \1 ; $147 - Cart type | |
| DB \2 ; $148 - ROM Size | |
| DB \3 ; $149 - RAM Size | |
| DB 1 ; $14a - Destination code | |
| DB $33 ; $14b - Old licensee code | |
| DB 0 ; $14c - Mask ROM version | |
| DB 0 ; $14d - Complement check (important) | |
| DW 0 ; $14e - Checksum (not important) | |
| ENDM |
| ; vi:syntax=rgbds | |
| ; https://github.com/nezticle/rgbds-template/blob/master/src/memory.asm | |
| SECTION "Memory1 Code",ROM0 | |
| INCLUDE "hardware.inc" | |
| ; Macro that pauses until VRAM available. | |
| lcd_WaitVRAM: MACRO | |
| ld a,[rSTAT] ; <---+ | |
| and STATF_BUSY ; | | |
| jr nz,@-4 ; ----+ | |
| ENDM | |
| PUSHS ; Push the current section onto assember stack. | |
| ;*************************************************************************** | |
| ;* | |
| ;* mem_Set - "Set" a memory region | |
| ;* | |
| ;* input: | |
| ;* a - value | |
| ;* hl - pMem | |
| ;* bc - bytecount | |
| ;* | |
| ;*************************************************************************** | |
| mem_Set:: | |
| inc b | |
| inc c | |
| jr .skip | |
| .loop ld [hl+],a | |
| .skip dec c | |
| jr nz,.loop | |
| dec b | |
| jr nz,.loop | |
| ret | |
| ;*************************************************************************** | |
| ;* | |
| ;* mem_Copy - "Copy" a memory region | |
| ;* | |
| ;* input: | |
| ;* hl - pSource | |
| ;* de - pDest | |
| ;* bc - bytecount | |
| ;* | |
| ;*************************************************************************** | |
| mem_Copy:: | |
| inc b | |
| inc c | |
| jr .skip | |
| .loop ld a,[hl+] | |
| ld [de],a | |
| inc de | |
| .skip dec c | |
| jr nz,.loop | |
| dec b | |
| jr nz,.loop | |
| ret | |
| ;*************************************************************************** | |
| ;* | |
| ;* mem_Copy - "Copy" a monochrome font from ROM to RAM | |
| ;* | |
| ;* input: | |
| ;* hl - pSource | |
| ;* de - pDest | |
| ;* bc - bytecount of Source | |
| ;* | |
| ;*************************************************************************** | |
| mem_CopyMono:: | |
| inc b | |
| inc c | |
| jr .skip | |
| .loop ld a,[hl+] | |
| ld [de],a | |
| inc de | |
| ld [de],a | |
| inc de | |
| .skip dec c | |
| jr nz,.loop | |
| dec b | |
| jr nz,.loop | |
| ret | |
| ;*************************************************************************** | |
| ;* | |
| ;* mem_SetVRAM - "Set" a memory region in VRAM | |
| ;* | |
| ;* input: | |
| ;* a - value | |
| ;* hl - pMem | |
| ;* bc - bytecount | |
| ;* | |
| ;*************************************************************************** | |
| mem_SetVRAM:: | |
| inc b | |
| inc c | |
| jr .skip | |
| .loop push af | |
| di | |
| lcd_WaitVRAM | |
| pop af | |
| ld [hl+],a | |
| ei | |
| .skip dec c | |
| jr nz,.loop | |
| dec b | |
| jr nz,.loop | |
| ret | |
| ;*************************************************************************** | |
| ;* | |
| ;* mem_CopyVRAM - "Copy" a memory region to or from VRAM | |
| ;* | |
| ;* input: | |
| ;* hl - pSource | |
| ;* de - pDest | |
| ;* bc - bytecount | |
| ;* | |
| ;*************************************************************************** | |
| mem_CopyVRAM:: | |
| inc b | |
| inc c | |
| jr .skip | |
| .loop di | |
| lcd_WaitVRAM | |
| ld a,[hl+] | |
| ld [de],a | |
| ei | |
| inc de | |
| .skip dec c | |
| jr nz,.loop | |
| dec b | |
| jr nz,.loop | |
| ret | |
| POPS ; Pop the current section off of assember stack. | |
| ; Made by tbsp, public domain | |
| ; CLASSIC_GAMEBOY_FONT.Z80 | |
| TilesFont:: | |
| DB $00,$00,$3C,$3C,$4E,$4E,$4E,$4E | |
| DB $7E,$7E,$4E,$4E,$4E,$4E,$00,$00 | |
| DB $00,$00,$7E,$7E,$60,$60,$7C,$7C | |
| DB $60,$60,$60,$60,$7E,$7E,$00,$00 | |
| DB $00,$00,$7C,$7C,$66,$66,$66,$66 | |
| DB $7C,$7C,$60,$60,$60,$60,$00,$00 | |
| DB $00,$00,$7C,$7C,$66,$66,$66,$66 | |
| DB $7C,$7C,$68,$68,$66,$66,$00,$00 | |
| DB $00,$00,$3C,$3C,$60,$60,$3C,$3C | |
| DB $0E,$0E,$4E,$4E,$3C,$3C,$00,$00 | |
| DB $00,$00,$7E,$7E,$18,$18,$18,$18 | |
| DB $18,$18,$18,$18,$18,$18,$00,$00 |
| ; vi:syntax=rgbds | |
| INCLUDE "hardware.inc" ; standard hardware definitions from devrs.com | |
| ; IRQs | |
| SECTION "Vblank",ROM0[$0040] | |
| ; push hl | |
| ; ld hl, VBLANK_FLAG | |
| ; ld [hl], 1 | |
| ; pop hl | |
| reti | |
| SECTION "LCDC",ROM0[$0048] | |
| reti | |
| SECTION "Timer_Overflow",ROM0[$0050] | |
| reti | |
| SECTION "Serial",ROM0[$0058] | |
| reti | |
| SECTION "p1thru4",ROM0[$0060] | |
| reti | |
| SECTION "FreeSpace",ROM0[$0068] | |
| INCLUDE "memory.inc" | |
| wait_vblank: | |
| ; push hl | |
| ; ld hl, VBLANK_FLAG | |
| ; xor a | |
| ;.wait: | |
| halt | |
| ; cp a, [hl] | |
| ; jr z, .wait | |
| ; ld [hl], a | |
| ; pop hl | |
| ret | |
| StartLCD: | |
| ld a, LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_BGON|LCDCF_OBJ8|LCDCF_OBJON | |
| ld [rLCDC], a | |
| ret | |
| StopLCD: | |
| ld a, [rLCDC] | |
| rlca ; Put the high bit of LCDC into the Carry flag | |
| ret nc ; Screen is off already. Exit. | |
| call wait_vblank | |
| ; Turn off the LCD | |
| ld a, [rLCDC] | |
| res 7, a ; Reset bit 7 of LCDC | |
| ld [rLCDC], a | |
| ret | |
| SECTION "start",ROM0[$0100] | |
| nop | |
| jp begin | |
| INCLUDE "header.inc" | |
| ROM_HEADER CART_ROM_MBC1_RAM_BAT, CART_ROM_256K, CART_RAM_16K | |
| SECTION "Game logic", ROM0 | |
| INCLUDE "splash.inc" | |
| begin: | |
| nop | |
| ld a, IEF_VBLANK | |
| ld [rIE], a | |
| ei | |
| ld sp, $e000 ; initialize the stack pointer | |
| init: | |
| ld a, %11100100 ; Window palette colors, from darkest to lightest | |
| ld [rBGP], a ; CLEAR THE SCREEN | |
| ; Load tiles | |
| ld a,0 ; SET SCREEN TO TO UPPER RIGHT HAND CORNER | |
| ld [rSCX], a | |
| ld [rSCY], a | |
| call StopLCD ; YOU CAN NOT LOAD $8000 WITH LCD ON | |
| ; Blank OAM | |
| ld a, $00 | |
| ld hl, _OAMRAM | |
| ld bc,$FE9F-_OAMRAM+1 | |
| call mem_Set | |
| ; Blank HRAM | |
| xor a | |
| ld hl, _HRAM | |
| ld bc, 63 | |
| call mem_Set | |
| ; Blank WRAM | |
| xor a | |
| ld hl, _RAM | |
| ld bc, $DFFD-_RAM+1 ; Don't clear stack | |
| call mem_Set | |
| ; BLANK VRAM | |
| ld a, $FF | |
| ld hl, _SCRN0 | |
| ld bc, _SCRN1-_SCRN0 | |
| call mem_SetVRAM | |
| ; Turn on LCD | |
| call StartLCD | |
| ld hl, TilesFont | |
| ld de, $8A00 | |
| ld bc, 96 | |
| call mem_CopyVRAM ; load tile data | |
| .place_sprites: | |
| call wait_vblank | |
| ld a, 110 | |
| ld [$fe00], a | |
| ld [$fe04], a | |
| ld [$fe08], a | |
| ld [$fe0c], a | |
| ld [$fe10], a | |
| ld [$fe14], a | |
| ld [$fe18], a | |
| ld [$fe1c], a | |
| ld [$fe20], a | |
| ld [$fe24], a | |
| ld a, 44 | |
| ld [$fe01], a | |
| ld a, $a2 | |
| ld [$fe02], a | |
| ld a, 52 | |
| ld [$fe05], a | |
| ld a, $a3 | |
| ld [$fe06], a | |
| ld a, 60 | |
| ld [$fe09], a | |
| ld a, $a1 | |
| ld [$fe0A], a | |
| ld a, 68 | |
| ld [$fe0D], a | |
| ld a, $a4 | |
| ld [$fe0E], a | |
| ld a, 76 | |
| ld [$fe11], a | |
| ld a, $a4 | |
| ld [$fe12], a | |
| call wait_vblank | |
| ld a, 94 | |
| ld [$fe15], a | |
| ld a, $a4 | |
| ld [$fe16], a | |
| ld a, 102 | |
| ld [$fe19], a | |
| ld a, $a5 | |
| ld [$fe1A], a | |
| ld a, 110 | |
| ld [$fe1D], a | |
| ld a, $a0 | |
| ld [$fe1E], a | |
| ld a, 118 | |
| ld [$fe21], a | |
| ld a, $a3 | |
| ld [$fe22], a | |
| ld a, 126 | |
| ld [$fe25], a | |
| ld a, $a5 | |
| ld [$fe26], a | |
| ld d, 0 | |
| .splash_loop: | |
| halt | |
| jr .splash_loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment