include "cpu/z80/include/common.inc" global screen_init_dsub global screen_seek_xy_dsub section code screen_init_dsub: exx ld a, CTRL_ENABLE_SPRITE_ROMS|CTRL_ENABLE_TILE_ROMS|CTRL_PALETTE_WRITE_REQUEST out (IO_CONTROL), a ; After requesting CTRL_PALETTE_WRITE_REQUEST on IO_CONTROL you ; need to wait for bit SYS2_PALETTE_WRITE_READY to be 1 on ; IO_INPUT_SYS2 before you start writing to palette ram. If ; you attempt write to palette ram before this the writes will ; be ignored. The bit however should get set to 1 at the next ; vblank. To avoid getting stuck polling IO_INPUT_SYS2 if ; there is a fault we are just doing a manual delay to get us ; to that vblank ld bc, $7ff NSUB delay ld hl, PALETTE_BASE ld de, PALETTE_SIZE ld c, $0 NSUB memory_fill ROMSET_PALETTE_SETUP ld a, CTRL_ENABLE_SPRITE_ROMS|CTRL_ENABLE_TILE_ROMS out (IO_CONTROL), a ld hl, TILE_BASE ld de, TILE_SIZE ifd _MGAKUEN_TEXT_ ld bc, $3000 else ld bc, $2000 endif NSUB memory_fill_word ; color index 0 on the first palette is the background ; color. However some games use that index for part of the ; text color. So we are using the 2nd palette for text ld hl, TILE_ATTR_BASE ld de, TILE_ATTR_SIZE ld c, $1 NSUB memory_fill ld a, VIDEO_BANK_SPRITE out (IO_VIDEO_BANK), a ld hl, SPRITE_BASE ld de, SPRITE_SIZE ld c, $00 NSUB memory_fill ld a, VIDEO_BANK_TILE out (IO_VIDEO_BANK), a SEEK_XY 11, 0 ld de, d_str_version NSUB print_string SEEK_XY 0, 1 ifd _MGAKUEN_TEXT_ ld c, $1d else ld c, '-' endif ld b, SCREEN_NUM_COLUMNS NSUB print_char_repeat SEEK_XY ((SCREEN_NUM_COLUMNS - _ROMSET_STR_LENGTH_) - 1), 1 ld de, d_str_romset NSUB print_string ; this likely isn't doing anything, see irq_handler ; for more info out (IO_SPRITE_COPY_REQUEST), a DSUB_RETURN ; b = x ; c = y screen_seek_xy_dsub: exx SEEK_XY 0, 0 ld a, b ; y offset ld b, c ld c, $0 sra b rr c add hl, bc ; x offset ld b, $0 sla a ld c, a add hl, bc DSUB_RETURN