Skip to content

Commit ae6be34

Browse files
authored
Merge pull request #1058 from boriel-basic/t-tang-main
Allows PRINT42 to use UDG
2 parents 77d8417 + a1146f4 commit ae6be34

2 files changed

Lines changed: 48 additions & 8 deletions

File tree

src/lib/arch/zx48k/stdlib/print42.bas

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ asm
3939
LOCAL examineChar
4040
examineChar:
4141
LD A,(HL) ; Grab the character at our pointer position
42-
CP 128 ; Too high to print?
42+
CP 165 ; Too high to print?
4343
JR NC, nextChar ; Then we go to the next
4444

45+
CP 144
46+
JR NC, prn ; char is a UDG
47+
48+
CP 128
49+
JR NC, nextChar ; char is a block graphic
50+
4551
CP 22 ; Is this an AT?
4652
JR NZ, isNewline ; If not jump over the AT routine to isNewline
4753

@@ -130,6 +136,9 @@ printachar:
130136
PUSH HL ; Store H'L' where we can get it.
131137
EXX
132138

139+
CP 144
140+
jr nc,printudg
141+
133142
ld c, a ; Put a copy of the character in C
134143
ld h, 0
135144
ld l, a ; Put the Character in HL
@@ -148,6 +157,19 @@ printachar:
148157
ld c, l ; Copy our character data address into BC
149158
jr printdata ; We have our data source, so we print it.
150159

160+
LOCAL printudg
161+
printudg
162+
sub 144 ; get the udg offset
163+
ld hl,$5C7B ; examine system variables for udg address
164+
ld e,(hl) ; lsb for udg address
165+
inc hl
166+
ld d,(hl) ; mbs for udg address
167+
ld l,a ; character offset for udg
168+
call mult8 ; multiplies L by 8 and adds in DE [so HL points at our table entry]
169+
ld b, h
170+
ld c, l ; Copy our character data address into BC
171+
jr printdata ; We have our data source, so we print it.
172+
151173
LOCAL calcChar
152174
calcChar: ; this is the calculate from the ROM data option
153175
; a holds the column kill data

tests/functional/arch/zx48k/print42.asm

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ _print42:
7373
LOCAL examineChar
7474
examineChar:
7575
LD A,(HL)
76+
CP 165
77+
JR NC, nextChar
78+
CP 144
79+
JR NC, prn
7680
CP 128
7781
JR NC, nextChar
7882
CP 22
@@ -144,6 +148,8 @@ printachar:
144148
EXX
145149
PUSH HL
146150
EXX
151+
CP 144
152+
jr nc,printudg
147153
ld c, a
148154
ld h, 0
149155
ld l, a
@@ -158,6 +164,18 @@ printachar:
158164
ld b, h
159165
ld c, l
160166
jr printdata
167+
LOCAL printudg
168+
printudg
169+
sub 144
170+
ld hl,$5C7B
171+
ld e,(hl)
172+
inc hl
173+
ld d,(hl)
174+
ld l,a
175+
call mult8
176+
ld b, h
177+
ld c, l
178+
jr printdata
161179
LOCAL calcChar
162180
calcChar:
163181
ld de, 15360
@@ -315,9 +333,9 @@ ycoord:
315333
ret c
316334
ld d, 0
317335
ret
318-
#line 329 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
336+
#line 351 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
319337
.LABEL._printAt42Coords:
320-
#line 330 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
338+
#line 352 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
321339
LOCAL xycoords
322340
xycoords:
323341
defb 0
@@ -491,7 +509,7 @@ characters:
491509
LOCAL print42end
492510
print42end:
493511
ENDP
494-
#line 522 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
512+
#line 544 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
495513
_print42__leave:
496514
ex af, af'
497515
exx
@@ -508,7 +526,7 @@ _print42__leave:
508526
exx
509527
ret
510528
;; --- end of user code ---
511-
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm"
529+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mem/free.asm"
512530
; vim: ts=4:et:sw=4:
513531
; Copyleft (K) by Jose M. Rodriguez de la Rosa
514532
; (a.k.a. Boriel)
@@ -568,7 +586,7 @@ _print42__leave:
568586
; HL = BLOCK Start & DE = Length.
569587
; An init directive is useful for initialization routines.
570588
; They will be added automatically if needed.
571-
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/heapinit.asm"
589+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mem/heapinit.asm"
572590
; vim: ts=4:et:sw=4:
573591
; Copyleft (K) by Jose M. Rodriguez de la Rosa
574592
; (a.k.a. Boriel)
@@ -675,7 +693,7 @@ __MEM_INIT2:
675693
ret
676694
ENDP
677695
pop namespace
678-
#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm"
696+
#line 69 "/zxbasic/src/lib/arch/zx48k/runtime/mem/free.asm"
679697
; ---------------------------------------------------------------------
680698
; MEM_FREE
681699
; Frees a block of memory
@@ -774,5 +792,5 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
774792
ret
775793
ENDP
776794
pop namespace
777-
#line 540 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
795+
#line 562 "/zxbasic/src/lib/arch/zx48k/stdlib/print42.bas"
778796
END

0 commit comments

Comments
 (0)