Skip to content

Commit 7a45ea7

Browse files
committed
Make usr "a" to also use UDG
USR "x" returns the mem address of UDG "x". "x" can be uppercase, lowercase or even the UDG itself
1 parent 3593074 commit 7a45ea7

4 files changed

Lines changed: 49 additions & 16 deletions

File tree

library-asm/usr_str.asm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include once <free.asm>
1111

1212
USR_STR:
13+
PROC
1314
ex af, af' ; Saves A flag
1415

1516
ld a, h
@@ -28,7 +29,14 @@ USR_STR:
2829
inc hl
2930
ld a, (hl) ; Only the 1st char is needed
3031
and 11011111b ; Convert it to UPPER CASE
32+
sub 144 ; CODE(UDG "A")
33+
jr nc, CONT
34+
adc a, 144 ; It was a letter
3135
sub 'A'
36+
37+
LOCAL CONT
38+
CONT:
39+
3240
ld l, a
3341
ld h, 0
3442
add hl, hl
@@ -58,4 +66,5 @@ USR_ERROR:
5866
ld (ERR_NR), a
5967
ld hl, 0
6068
ret
69+
ENDP
6170

tests/functional/fastcall0.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
11751175
ENDP
11761176
#line 11 "usr_str.asm"
11771177
USR_STR:
1178+
PROC
11781179
ex af, af' ; Saves A flag
11791180
ld a, h
11801181
or l
@@ -1189,7 +1190,12 @@ USR_STR:
11891190
inc hl
11901191
ld a, (hl) ; Only the 1st char is needed
11911192
and 11011111b ; Convert it to UPPER CASE
1193+
sub 144 ; CODE(UDG "A")
1194+
jr nc, CONT
1195+
adc a, 144 ; It was a letter
11921196
sub 'A'
1197+
LOCAL CONT
1198+
CONT:
11931199
ld l, a
11941200
ld h, 0
11951201
add hl, hl
@@ -1215,6 +1221,7 @@ USR_ERROR:
12151221
ld (ERR_NR), a
12161222
ld hl, 0
12171223
ret
1224+
ENDP
12181225
#line 472 "fastcall0.bas"
12191226
ZXBASIC_USER_DATA:
12201227
ZXBASIC_MEM_HEAP:

tests/functional/spfill.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
11751175
ENDP
11761176
#line 11 "usr_str.asm"
11771177
USR_STR:
1178+
PROC
11781179
ex af, af' ; Saves A flag
11791180
ld a, h
11801181
or l
@@ -1189,7 +1190,12 @@ USR_STR:
11891190
inc hl
11901191
ld a, (hl) ; Only the 1st char is needed
11911192
and 11011111b ; Convert it to UPPER CASE
1193+
sub 144 ; CODE(UDG "A")
1194+
jr nc, CONT
1195+
adc a, 144 ; It was a letter
11921196
sub 'A'
1197+
LOCAL CONT
1198+
CONT:
11931199
ld l, a
11941200
ld h, 0
11951201
add hl, hl
@@ -1215,6 +1221,7 @@ USR_ERROR:
12151221
ld (ERR_NR), a
12161222
ld hl, 0
12171223
ret
1224+
ENDP
12181225
#line 472 "spfill.bas"
12191226
ZXBASIC_USER_DATA:
12201227
ZXBASIC_MEM_HEAP:

tests/functional/usr0.asm

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ __LABEL0:
3939
DEFW 0001h
4040
DEFB 41h
4141
#line 1 "print.asm"
42+
; vim:ts=4:sw=4:et:
4243
; vim:ts=4:sw=4:et:
4344
; PRINT command routine
4445
; Does not print attribute. Use PRINT_STR or PRINT_NUM for that
@@ -66,7 +67,7 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var.
6667
POSX EQU S_POSN ; Current POS X
6768
POSY EQU S_POSN + 1 ; Current POS Y
6869
ENDP
69-
#line 6 "print.asm"
70+
#line 7 "print.asm"
7071
#line 1 "cls.asm"
7172
; JUMPS directly to spectrum CLS
7273
; This routine does not clear lower screen
@@ -103,7 +104,7 @@ __CLS_SCR:
103104
SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines
104105
; to get the start of the screen
105106
ENDP
106-
#line 7 "print.asm"
107+
#line 8 "print.asm"
107108
#line 1 "in_screen.asm"
108109
#line 1 "error.asm"
109110
; Simple error control routines
@@ -159,7 +160,7 @@ __OUT_OF_SCREEN_ERR:
159160
ld a, ERROR_OutOfScreen
160161
jp __STOP ; Saves error code and exits
161162
ENDP
162-
#line 8 "print.asm"
163+
#line 9 "print.asm"
163164
#line 1 "table_jump.asm"
164165
JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A
165166
add a, a
@@ -174,7 +175,7 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE)
174175
ex de, hl
175176
CALL_HL:
176177
jp (hl)
177-
#line 9 "print.asm"
178+
#line 10 "print.asm"
178179
#line 1 "ink.asm"
179180
; Sets ink color in ATTR_P permanently
180181
; Parameter: Paper color in A register
@@ -219,7 +220,7 @@ INK_TMP:
219220
ld de, ATTR_T
220221
jp __SET_INK
221222
ENDP
222-
#line 10 "print.asm"
223+
#line 11 "print.asm"
223224
#line 1 "paper.asm"
224225
; Sets paper color in ATTR_P permanently
225226
; Parameter: Paper color in A register
@@ -257,7 +258,7 @@ PAPER_TMP:
257258
ld de, ATTR_T
258259
jp __SET_PAPER
259260
ENDP
260-
#line 11 "print.asm"
261+
#line 12 "print.asm"
261262
#line 1 "flash.asm"
262263
; Sets flash flag in ATTR_P permanently
263264
; Parameter: Paper color in A register
@@ -292,7 +293,7 @@ FLASH_TMP:
292293
ld hl, ATTR_T
293294
jr __SET_FLASH
294295
ENDP
295-
#line 12 "print.asm"
296+
#line 13 "print.asm"
296297
#line 1 "bright.asm"
297298
; Sets bright flag in ATTR_P permanently
298299
; Parameter: Paper color in A register
@@ -327,7 +328,7 @@ BRIGHT_TMP:
327328
ld hl, ATTR_T
328329
jr __SET_BRIGHT
329330
ENDP
330-
#line 13 "print.asm"
331+
#line 14 "print.asm"
331332
#line 1 "over.asm"
332333
; Sets OVER flag in P_FLAG permanently
333334
; Parameter: OVER flag in bit 0 of A register
@@ -416,7 +417,7 @@ OVER_TMP:
416417
ld (hl), a
417418
jp __SET_ATTR_MODE
418419
ENDP
419-
#line 14 "print.asm"
420+
#line 15 "print.asm"
420421
#line 1 "inverse.asm"
421422
; Sets INVERSE flag in P_FLAG permanently
422423
; Parameter: INVERSE flag in bit 0 of A register
@@ -442,7 +443,7 @@ INVERSE_TMP:
442443
ld (hl), a
443444
jp __SET_ATTR_MODE
444445
ENDP
445-
#line 15 "print.asm"
446+
#line 16 "print.asm"
446447
#line 1 "bold.asm"
447448
; Sets BOLD flag in P_FLAG permanently
448449
; Parameter: BOLD flag in bit 0 of A register
@@ -468,7 +469,7 @@ BOLD_TMP:
468469
ld (hl), a
469470
ret
470471
ENDP
471-
#line 16 "print.asm"
472+
#line 17 "print.asm"
472473
#line 1 "italic.asm"
473474
; Sets ITALIC flag in P_FLAG permanently
474475
; Parameter: ITALIC flag in bit 0 of A register
@@ -496,7 +497,7 @@ ITALIC_TMP:
496497
ld (hl), a
497498
ret
498499
ENDP
499-
#line 17 "print.asm"
500+
#line 18 "print.asm"
500501
#line 1 "attr.asm"
501502
; Attribute routines
502503
; vim:ts=4:et:sw:
@@ -554,7 +555,7 @@ SET_PIXEL_ADDR_ATTR:
554555
ld de, (SCREEN_ADDR)
555556
add hl, de ;; Final screen addr
556557
jp __SET_ATTR2
557-
#line 19 "print.asm"
558+
#line 20 "print.asm"
558559
; Putting a comment starting with @INIT <address>
559560
; will make the compiler to add a CALL to <address>
560561
; It is useful for initialization routines.
@@ -594,14 +595,14 @@ __SCROLL: ; Scroll?
594595
ld hl, __TVFLAGS
595596
res 1, (hl)
596597
ret
597-
#line 75 "/zxbasic/library-asm/print.asm"
598+
#line 76 "/zxbasic/library-asm/print.asm"
598599
__PRINT_START:
599600
cp ' '
600601
jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones
601602
exx ; Switch to alternative registers
602603
ex af, af' ; Saves a value (char to print) for later
603604
call __SCROLL
604-
#line 86 "/zxbasic/library-asm/print.asm"
605+
#line 87 "/zxbasic/library-asm/print.asm"
605606
call __LOAD_S_POSN
606607
; At this point we have the new coord
607608
ld hl, (SCREEN_ADDR)
@@ -696,7 +697,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence
696697
exx
697698
__PRINT_0Dh: ; Called WHEN printing CHR$(13)
698699
call __SCROLL
699-
#line 209 "/zxbasic/library-asm/print.asm"
700+
#line 210 "/zxbasic/library-asm/print.asm"
700701
call __LOAD_S_POSN
701702
__PRINT_EOL1: ; Another entry called from PRINT when next line required
702703
ld e, 0
@@ -710,6 +711,7 @@ __PRINT_AT1_END:
710711
ld hl, __TVFLAGS
711712
set 1, (hl)
712713
ld a, d
714+
#line 230 "/zxbasic/library-asm/print.asm"
713715
__PRINT_EOL_END:
714716
ld d, a
715717
__PRINT_AT2_END:
@@ -922,6 +924,7 @@ PRINT_AT: ; Changes cursor to ROW, COL
922924
ret nc ; Return if out of screen
923925
ld hl, __TVFLAGS
924926
res 1, (hl)
927+
#line 482 "/zxbasic/library-asm/print.asm"
925928
jp __SAVE_S_POSN
926929
LOCAL __PRINT_COM
927930
LOCAL __BOLD
@@ -1378,6 +1381,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed
13781381
ENDP
13791382
#line 11 "usr_str.asm"
13801383
USR_STR:
1384+
PROC
13811385
ex af, af' ; Saves A flag
13821386
ld a, h
13831387
or l
@@ -1392,7 +1396,12 @@ USR_STR:
13921396
inc hl
13931397
ld a, (hl) ; Only the 1st char is needed
13941398
and 11011111b ; Convert it to UPPER CASE
1399+
sub 144 ; CODE(UDG "A")
1400+
jr nc, CONT
1401+
adc a, 144 ; It was a letter
13951402
sub 'A'
1403+
LOCAL CONT
1404+
CONT:
13961405
ld l, a
13971406
ld h, 0
13981407
add hl, hl
@@ -1418,6 +1427,7 @@ USR_ERROR:
14181427
ld (ERR_NR), a
14191428
ld hl, 0
14201429
ret
1430+
ENDP
14211431
#line 28 "usr0.bas"
14221432
ZXBASIC_USER_DATA:
14231433
ZXBASIC_MEM_HEAP:

0 commit comments

Comments
 (0)