Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ORG #8000
- stringposition:
- defb 0
- nextletter:
- LD B,0 ;y coord of getpixel
- LD C,200 ; x coord of get pixel
- LD A,(stringposition) ;get string position
- SLA A
- SLA A
- SLA A ;multiply stringposition by 8
- ADD A,C
- LD C,A ;add string position to x-coordinate
- call Get_Pixel_Address
- PUSH HL
- LD IX,font ;load font memory position
- LD DE,mystring ; load string memory position
- LD A,(stringposition)
- LD B,A ;
- CP 0 ; add string position and
- JP Z,dontinc1 ;mystring memory address together
- ;
- incagain1: ;
- INC DE ;
- DJNZ incagain1 ;
- dontinc1: ;
- LD A,(DE) ;memory address of letter to be printed is in de
- SUB 32 ;ASCII has 31 unprintable characters
- LD B,A
- LD DE,8
- POP HL
- mLoop:
- ADD IX,DE
- djnz mLoop
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- INC H
- INC IX
- LD A,(IX)
- LD (HL),A
- LD HL,stringposition
- INC (HL)
- LD DE,mystring ;
- LD A,(stringposition) ;
- LD B,A ;add string position to string
- incagain: ;to get current letter
- INC DE ;
- DJNZ incagain ;
- LD A,(DE)
- CP 0
- JP NZ,nextletter
- ; Get screen address
- ; B = Y pixel position
- ; C = X pixel position
- ; Returns address in HL
- ;
- mystring:
- defb "hello",#0
- screen_address:
- defw 0
- Get_Pixel_Address: LD A,B ; Calculate Y2,Y1,Y0
- AND %00000111 ; Mask out unwanted bits
- OR %01000000 ; Set base address of screen
- LD H,A ; Store in H
- LD A,B ; Calculate Y7,Y6
- RRA ; Shift to position
- RRA
- RRA
- AND %00011000 ; Mask out unwanted bits
- OR H ; OR with Y2,Y1,Y0
- LD H,A ; Store in H
- LD A,B ; Calculate Y5,Y4,Y3
- RLA ; Shift to position
- RLA
- AND %11100000 ; Mask out unwanted bits
- LD L,A ; Store in L
- LD A,C ; Calculate X4,X3,X2,X1,X0
- RRA ; Shift into position
- RRA
- RRA
- AND %00011111 ; Mask out unwanted bits
- OR L ; OR with Y5,Y4,Y3
- LD L,A ; Store in L
- RET
- include "font.zas"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement