here:
Code: Select all
org 40000
ld a,32
call $0daf
loop
inc a
rst 16
jr loop
Code: Select all
org 40000
ld a,32
call $0daf
loop
inc a
rst 16
jr loop
Code: Select all
ORG 40000
CALL 3503
LD A,32
LOOP:
CP 128
RET Z
PUSH AF
RST 16
POP AF
INC A
JR LOOP
Code: Select all
org 40000
call $0daf
ld a,32
loop:
push af
rst 16
pop af
inc a
jp p,loop
ret
thank you. how would i incorporate code to print to the screen without using rom calls?Alessandro wrote: ↑Mon Jul 10, 2023 3:18 pm You also need to check if A hits 128 (CP 128), exiting the loop in that case (RET Z), if you want to print the character set only.
Code: Select all
org 40000
LD A, 65 ; Character to print
; LD D, 1 ; Y position
; LD E, 15 ; X position
CALL Print_Char ; Print the character
RET
;
; Print a single character out to a screen address
; A: Character to print
; D: Character Y position
; E: Character X position
;
Print_Char: LD HL, 0x3C00 ; Character set bitmap data in ROM
LD B,0 ; BC = character code
LD C, A
SLA C ; Multiply by 8 by shifting
RL B
SLA C
RL B
SLA C
RL B
ADD HL, BC ; And add to HL to get first byte of character
; CALL Get_Char_Address ; Get screen position in DE
LD B,8 ; Loop counter - 8 bytes per character
Print_Char_L1: LD A,(HL) ; Get the byte from the ROM into A
LD (DE),A ; Stick A onto the screen
INC HL ; Goto next byte of character
INC D ; Goto next line on screen
DJNZ Print_Char_L1 ; Loop around whilst it is Not Zero (NZ)
RET
; Get screen address from a character (X,Y) coordinate
; D = Y character position (0-23)
; E = X character position (0-31)
; Returns screen address in DE
;
Get_Char_Address: LD A,D
AND %00000111
RRA
RRA
RRA
RRA
OR E
LD E,A
LD A,D
AND %00011000
OR %01000000
LD D,A
RET ; Returns screen address in DE
Code: Select all
org 40000
LD D, 1 ; Y position
LD E, 15 ; X position
CALL Print_Char ; Print the character
RET
;
; Print a single character out to a screen address;
; D: Character Y position
; E: Character X position
;
Print_Char: LD HL, Graphic ; ** Where your graphic is stored **
CALL Get_Char_Address ; Get screen position in DE
LD B,8 ; Loop counter - 8 bytes per character
Print_Char_L1: LD A,(HL) ; Get the byte from the ROM into A
LD (DE),A ; Stick A onto the screen
INC HL ; Goto next byte of character
INC D ; Goto next line on screen
DJNZ Print_Char_L1 ; Loop around whilst it is Not Zero (NZ)
RET
; Get screen address from a character (X,Y) coordinate
; D = Y character position (0-23)
; E = X character position (0-31)
; Returns screen address in DE
;
Get_Char_Address: LD A,D
AND %00000111
RRA
RRA
RRA
RRA
OR E
LD E,A
LD A,D
AND %00011000
OR %01000000
LD D,A
RET ; Returns screen address in DE
Graphic: DEFB 255, 129, 129, 129, 129, 129, 129, 255