Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; @brief Writes a character to the screen at the current coordinates
- ; @param c Character to print
- ; @destroy a
- ; @destroy de
- ; @destroy hl
- Printputc:
- ; This will put PrintY into d and PrintX into e
- ld hl, PrintX
- ld a, [hli]
- ld e, a
- ld a, [hl]
- ld d, a
- ld h, 0 ;
- ld l, d ;
- ;
- rept 5 ;
- add hl, hl ; Multiply y coordinate by 32 to get visible screen space location
- endr
- ; Add map base offset
- ld a, h
- add $98
- ld h, a
- ; Add x coordinate offset
- ld a, e
- add l
- ld l, a
- ld [hl], c
- ; Update coordinates
- inc e
- .checkX
- ld a, PrintMaxX
- cp a, e
- jr nc, .checkY
- ld e, 0
- inc d
- .checkY
- ld a, PrintMaxY
- cp a, d
- jr nc, .storeCoords
- ld d, 0
- .storeCoords
- ld a, d
- ld [PrintY], a
- ld a, e
- ld [PrintX], a
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement