;---------------------------------------------------------------; ; ; ; Snail Maze ; ; Text routines ; ; ; ;---------------------------------------------------------------; ;------------------------------------------------ ; printString - print a string to vBuf ; input: IX => string ; DE = x pos ; L = y pos ; output: IX => data after string ;------------------------------------------------ printString: ld a,(ix) inc ix or a ; null terminator? ret z push ix push hl push de sub $20 ld bc,0 ld c,a ; BC = textTable offset ld hl,textTable add hl,bc ld c,(hl) ; C = character sprite to show ld b,CHAR_SPRITE_SIZE mlt bc ld hl,sprChars add hl,bc ; HL => sprite to show ld de,charBuffer ld a,(hl) \ ld (de),a inc hl \ inc de ld a,(hl) \ ld (de),a inc hl \ inc de ld b,CHAR_SPRITE_SIZE-2 charLoop: ld a,(hl) or a jr z,loadChar ld a,$01 __charColour = $-1 loadChar: ld (de),a inc hl \ inc de djnz charLoop ld ix,charBuffer pop de pop hl push hl push de call drawSprite pop de ld hl,CHAR_WIDTH add hl,de ex de,hl ; DE = next x pos pop hl ; HL = y pos pop ix jr printString ;------------------------------------------------ ; printHL - print HL right-aligned using specified number of characters (left will be padded with spaces) ; input: HL = value to show ; B = # chars to show ; DE = x pos ; C = y pos ; output: none ;------------------------------------------------ printHL: push de push bc ld de,strBuffer printHLIni: inc de djnz printHLIni pop bc \ push bc xor a ld (de),a ; write null terminator printHLMake: dec de bcall(_divHLby10_s) add a,'0' ; A = character to display ld (de),a djnz printHLMake push de \ pop ix ; IX => start of string ; check string and elimate leading zeros with spaces pop bc \ push bc \ dec b ; get original B counter a decrement to calc max number of zeros to elimate printHLCheck: ld a,(ix) cp '0' jr nz,printHLReady ld (ix),' ' inc ix djnz printHLCheck printHLReady: ld ix,strBuffer pop hl pop de jp printString textTable: .db 0,1,0,0,0,0,0,0,0,0,0,0,0,0,2,0 ; $20-$2F .db 3,4,5,6,7,8,9,10,11,12,0,0,0,0,0,0 ; $30-$3F .db 0,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27 ; $40-4F .db 28,29,30,31,32,33,34,35,36,37,38,0,0,0,0,0 ; $50-$5F .end