IIMarckus
J946@5488AA97464
- 402
- Posts
- 17
- Years
- Seen Feb 21, 2024
PRINT TEXT
Writes a text box to screen.
- load hl with the pointer to the starting textcode (usually 00h)
- call $0F5E [G/S] or $1057 [C]
Example:
COPY DATA
Copies a set number of bytes from one location to another.
- load hl with location of data to be copied
- load de with location to copy to
- load bc with the length of the data in bytes
- call $311A [G/S] or $3026 [C]
COPY TILES
Writes tiles (including text variables) to screen. No length is given; it copies until reaching a 50h.
- load hl with the tilemap location (G/S: $C3A0-$C507; Crystal: $C4A0-$C607)
- load de with the pointer to the tiles
- call $0F74 [G/S] or $1078 [C]
Example:
PLAY MUSIC
Starts playing background music.
- load de with the song number
- call $3D98 [G/S] or $3B97 [C]
Example:
PLAY SOUND
Plays a sound effect.
- load de with the sound number
- call $3E24 [G/S] or $3C23 [C]
Example:
BANKSWITCH (HOME)
Use this ONLY when PC is in the home ROM bank ($0000-$3FFF), or else you'll wind up in the middle of unrelated code! This changes the ROM bank currently in $4000-$7FFF, but not the location of the program counter.
- load a with the bank number
- rst $10 [G/S/C]
Example:
BANKSWITCH
Use this when PC is in the switchable ROM bank ($4000-$7FFF).
- load a with the bank number
- load hl with the location within the bank you want to switch to
- rst $08 [G/S/C]
Example:
USEFUL RAM LOCATIONS
CURRENT ROM BANK
If you ever need to know what ROM bank you're in, read the byte at $FF9F [G/S] or $FF9D [C].
Example:
TILEMAP
Locations $C3A0-$C507 [G/S] and $C4A0-$C607 [C] each represent a background tile on the screen. $C3A0 [G/S] is the first tile of the first row, $C3B4 [G/S] is the second tile of the first row, and so on. Write a value to one of these bytes, and the corresponding background tile will appear in that location on the screen.
Example:
If you've found some good in-game routines (or coded your own), feel free to post it here.
Writes a text box to screen.
- load hl with the pointer to the starting textcode (usually 00h)
- call $0F5E [G/S] or $1057 [C]
Example:
Code:
21 3C 42 ld hl,$423C
CD 5E 0F call $0F5E
COPY DATA
Copies a set number of bytes from one location to another.
- load hl with location of data to be copied
- load de with location to copy to
- load bc with the length of the data in bytes
- call $311A [G/S] or $3026 [C]
COPY TILES
Writes tiles (including text variables) to screen. No length is given; it copies until reaching a 50h.
- load hl with the tilemap location (G/S: $C3A0-$C507; Crystal: $C4A0-$C607)
- load de with the pointer to the tiles
- call $0F74 [G/S] or $1078 [C]
Example:
Code:
21 E9 C4 ld hl,$C4E9
11 00 40 ld de,$4000
CD 74 0F call $0F74
PLAY MUSIC
Starts playing background music.
- load de with the song number
- call $3D98 [G/S] or $3B97 [C]
Example:
Code:
11 01 00 ld de,$0001
CD 98 3D call $3D98
PLAY SOUND
Plays a sound effect.
- load de with the sound number
- call $3E24 [G/S] or $3C23 [C]
Example:
Code:
11 17 00 ld de,$0017
CD 24 3E call $3D98
BANKSWITCH (HOME)
Use this ONLY when PC is in the home ROM bank ($0000-$3FFF), or else you'll wind up in the middle of unrelated code! This changes the ROM bank currently in $4000-$7FFF, but not the location of the program counter.
- load a with the bank number
- rst $10 [G/S/C]
Example:
Code:
3E 08 ld a,$08
D7 rst $10
BANKSWITCH
Use this when PC is in the switchable ROM bank ($4000-$7FFF).
- load a with the bank number
- load hl with the location within the bank you want to switch to
- rst $08 [G/S/C]
Example:
Code:
3E 16 ld a,$16
21 00 40 ld hl,$4000
CF rst $08
USEFUL RAM LOCATIONS
CURRENT ROM BANK
If you ever need to know what ROM bank you're in, read the byte at $FF9F [G/S] or $FF9D [C].
Example:
Code:
F0 9F ld a,[$FF9F]
TILEMAP
Locations $C3A0-$C507 [G/S] and $C4A0-$C607 [C] each represent a background tile on the screen. $C3A0 [G/S] is the first tile of the first row, $C3B4 [G/S] is the second tile of the first row, and so on. Write a value to one of these bytes, and the corresponding background tile will appear in that location on the screen.
Example:
Code:
3E 0A ld a,$0A
EA 4E C4 ld ($C44E),a
If you've found some good in-game routines (or coded your own), feel free to post it here.
Last edited: