Skip to content

Commit

Permalink
Merge pull request #820 from boriel-basic/fix/TV-FLAG_initialization
Browse files Browse the repository at this point in the history
fix: initialize TV_FLAG correctly
  • Loading branch information
boriel authored Oct 6, 2024
2 parents 29de5a0 + 41d1259 commit c66077e
Show file tree
Hide file tree
Showing 100 changed files with 1,935 additions and 1,860 deletions.
3 changes: 2 additions & 1 deletion src/lib/arch/zx48k/runtime/print.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ __PRINT_INIT: ; To be called before program starts (initializes library)
;; Clears ATTR2 flags (OVER 2, etc)
xor a
ld (FLAGS2), a
ld (TVFLAGS), a
ld hl, TV_FLAG
res 0, (hl)

LOCAL SET_SCR_ADDR
call __LOAD_S_POSN
Expand Down
12 changes: 6 additions & 6 deletions src/lib/arch/zx48k/runtime/sysvars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.)

; These are mapped onto ZX Spectrum ROM VARS

CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TVFLAGS EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TV_FLAG EQU 23612 ; Flags for controlling output to screen
UDG EQU 23675 ; Pointer to UDG Charset
COORDS EQU 23677 ; Last PLOT coordinates
FLAGS2 EQU 23681 ;
FLAGS2 EQU 23681 ;
ECHO_E EQU 23682 ;
DFCC EQU 23684 ; Next screen addr for PRINT
DFCCL EQU 23686 ; Next screen attr for PRINT
S_POSN EQU 23688
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars

SCR_COLS EQU 33 ; Screen with in columns + 1
Expand Down
3 changes: 2 additions & 1 deletion src/lib/arch/zxnext/runtime/print.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ __PRINT_INIT: ; To be called before program starts (initializes library)
;; Clears ATTR2 flags (OVER 2, etc)
xor a
ld (FLAGS2), a
ld (TVFLAGS), a
ld hl, TV_FLAG
res 0, (hl)

LOCAL SET_SCR_ADDR
call __LOAD_S_POSN
Expand Down
12 changes: 6 additions & 6 deletions src/lib/arch/zxnext/runtime/sysvars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.)

; These are mapped onto ZX Spectrum ROM VARS

CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TVFLAGS EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TV_FLAG EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
COORDS EQU 23677 ; Last PLOT coordinates
FLAGS2 EQU 23681 ;
FLAGS2 EQU 23681 ;
ECHO_E EQU 23682 ;
DFCC EQU 23684 ; Next screen addr for PRINT
DFCCL EQU 23686 ; Next screen attr for PRINT
S_POSN EQU 23688
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars

SCR_COLS EQU 33 ; Screen with in columns + 1
Expand Down
39 changes: 20 additions & 19 deletions tests/functional/arch/zx48k/astore16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,18 @@ TMP_ARR_PTR:
SCREEN_ADDR: DW 16384 ; Screen address (can be pointed to other place to use a screen buffer)
SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.)
; These are mapped onto ZX Spectrum ROM VARS
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TVFLAGS EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TV_FLAG EQU 23612 ; Flags for controlling output to screen
UDG EQU 23675 ; Pointer to UDG Charset
COORDS EQU 23677 ; Last PLOT coordinates
FLAGS2 EQU 23681 ;
FLAGS2 EQU 23681 ;
ECHO_E EQU 23682 ;
DFCC EQU 23684 ; Next screen addr for PRINT
DFCCL EQU 23686 ; Next screen attr for PRINT
S_POSN EQU 23688
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars
SCR_COLS EQU 33 ; Screen with in columns + 1
SCR_ROWS EQU 24 ; Screen height in rows
Expand Down Expand Up @@ -729,7 +729,8 @@ __PRINT_INIT: ; To be called before program starts (initializes library)
;; Clears ATTR2 flags (OVER 2, etc)
xor a
ld (FLAGS2), a
ld (TVFLAGS), a
ld hl, TV_FLAG
res 0, (hl)
LOCAL SET_SCR_ADDR
call __LOAD_S_POSN
jp __SET_SCR_PTR
Expand Down Expand Up @@ -772,7 +773,7 @@ __PRINT_CHR:
push hl
call __SCROLL_SCR
pop hl
#line 93 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 94 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
2:
call SET_SCR_ADDR
jr 4f
Expand Down Expand Up @@ -808,10 +809,10 @@ __PRGRAPH:
ex de, hl ; HL = Write Address, DE = CHARS address
bit 2, (iy + $47)
call nz, __BOLD
#line 140 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 141 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
bit 4, (iy + $47)
call nz, __ITALIC
#line 145 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 146 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
ld hl, (DFCC)
push hl
ld b, 8 ; 8 bytes per char
Expand Down Expand Up @@ -860,7 +861,7 @@ __PRINT_0Dh: ; Called WHEN printing CHR$(13)
push hl
call __SCROLL_SCR
pop hl
#line 210 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 211 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
1:
ld l, 1
__PRINT_EOL_END:
Expand Down Expand Up @@ -977,14 +978,14 @@ __PRINT_BOLD:
__PRINT_BOLD2:
call BOLD_TMP
jp __PRINT_RESTART
#line 354 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 355 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
__PRINT_ITA:
ld hl, __PRINT_ITA2
jp __PRINT_SET_STATE
__PRINT_ITA2:
call ITALIC_TMP
jp __PRINT_RESTART
#line 364 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 365 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
LOCAL __BOLD
__BOLD:
push hl
Expand All @@ -1002,7 +1003,7 @@ __BOLD:
pop hl
ld de, MEM0
ret
#line 385 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 386 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
LOCAL __ITALIC
__ITALIC:
push hl
Expand All @@ -1027,12 +1028,12 @@ __ITALIC:
pop hl
ld de, MEM0
ret
#line 413 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 414 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
LOCAL __SCROLL_SCR
#line 487 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 488 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
__SCROLL_SCR EQU 0DFEh ; Use ROM SCROLL
#line 489 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 490 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 491 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
PRINT_COMMA:
call __LOAD_S_POSN
ld a, e
Expand Down Expand Up @@ -1075,9 +1076,9 @@ PRINT_AT: ; Changes cursor to ROW, COL
LOCAL __PRINT_TABLE
LOCAL __PRINT_TAB, __PRINT_TAB1, __PRINT_TAB2
LOCAL __PRINT_ITA2
#line 546 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 547 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
LOCAL __PRINT_BOLD2
#line 552 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
#line 553 "/zxbasic/src/lib/arch/zx48k/runtime/print.asm"
__PRINT_TABLE: ; Jump table for 0 .. 22 codes
DW __PRINT_NOP ; 0
DW __PRINT_NOP ; 1
Expand Down
46 changes: 23 additions & 23 deletions tests/functional/arch/zx48k/attr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
ei
ret
;; --- end of user code ---
#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bold.asm"
; Sets BOLD flag in P_FLAG permanently
; Parameter: BOLD flag in bit 0 of A register
#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm"
#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/sysvars.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/copy_attr.asm"
#line 4 "/zxbasic/src/lib/arch/zx48k/runtime/copy_attr.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sysvars.asm"
;; -----------------------------------------------------------------------
;; ZX Basic System Vars
;; Some of them will be mapped over Sinclair ROM ones for compatibility
Expand All @@ -59,24 +59,24 @@
SCREEN_ADDR: DW 16384 ; Screen address (can be pointed to other place to use a screen buffer)
SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.)
; These are mapped onto ZX Spectrum ROM VARS
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TVFLAGS EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TV_FLAG EQU 23612 ; Flags for controlling output to screen
UDG EQU 23675 ; Pointer to UDG Charset
COORDS EQU 23677 ; Last PLOT coordinates
FLAGS2 EQU 23681 ;
FLAGS2 EQU 23681 ;
ECHO_E EQU 23682 ;
DFCC EQU 23684 ; Next screen addr for PRINT
DFCCL EQU 23686 ; Next screen attr for PRINT
S_POSN EQU 23688
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars
SCR_COLS EQU 33 ; Screen with in columns + 1
SCR_ROWS EQU 24 ; Screen height in rows
SCR_SIZE EQU (SCR_ROWS << 8) + SCR_COLS
pop namespace
#line 6 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm"
#line 6 "/zxbasic/src/lib/arch/zx48k/runtime/copy_attr.asm"
push namespace core
COPY_ATTR:
; Just copies current permanent attribs into temporal attribs
Expand All @@ -92,9 +92,9 @@ COPY_ATTR:
ld hl, P_FLAG
call __REFRESH_TMP
__SET_ATTR_MODE: ; Another entry to set print modes. A contains (P_FLAG)
#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm"
#line 65 "/zxbasic/src/lib/arch/zx48k/runtime/copy_attr.asm"
ret
#line 67 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm"
#line 67 "/zxbasic/src/lib/arch/zx48k/runtime/copy_attr.asm"
__REFRESH_TMP:
ld a, (hl)
and 0b10101010
Expand All @@ -105,7 +105,7 @@ __REFRESH_TMP:
ret
ENDP
pop namespace
#line 4 "/zxbasic/src/arch/zx48k/library-asm/bold.asm"
#line 4 "/zxbasic/src/lib/arch/zx48k/runtime/bold.asm"
push namespace core
BOLD:
PROC
Expand All @@ -130,8 +130,8 @@ BOLD_TMP:
ret
ENDP
pop namespace
#line 27 "zx48k/attr.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm"
#line 27 "arch/zx48k/attr.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/flash.asm"
; Sets flash flag in ATTR_P permanently
; Parameter: Paper color in A register
push namespace core
Expand Down Expand Up @@ -167,8 +167,8 @@ FLASH_TMP:
jr __SET_FLASH
ENDP
pop namespace
#line 28 "zx48k/attr.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm"
#line 28 "arch/zx48k/attr.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/ink.asm"
; Sets ink color in ATTR_P permanently
; Parameter: Paper color in A register
push namespace core
Expand Down Expand Up @@ -204,8 +204,8 @@ INK_TMP:
jp __SET_INK
ENDP
pop namespace
#line 29 "zx48k/attr.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm"
#line 29 "arch/zx48k/attr.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/over.asm"
; Sets OVER flag in P_FLAG permanently
; Parameter: OVER flag in bit 0 of A register
push namespace core
Expand Down Expand Up @@ -243,8 +243,8 @@ OVER_TMP:
jp __SET_ATTR_MODE
ENDP
pop namespace
#line 30 "zx48k/attr.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm"
#line 30 "arch/zx48k/attr.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/paper.asm"
; Sets paper color in ATTR_P permanently
; Parameter: Paper color in A register
push namespace core
Expand Down Expand Up @@ -283,5 +283,5 @@ PAPER_TMP:
jp __SET_PAPER
ENDP
pop namespace
#line 31 "zx48k/attr.bas"
#line 31 "arch/zx48k/attr.bas"
END
32 changes: 16 additions & 16 deletions tests/functional/arch/zx48k/attr_in_subs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ _screenAttributes2__leave:
pop ix
ret
;; --- end of user code ---
#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bright.asm"
; Sets bright flag in ATTR_P permanently
; Parameter: Paper color in A register
#line 1 "/zxbasic/src/arch/zx48k/library-asm/sysvars.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sysvars.asm"
;; -----------------------------------------------------------------------
;; ZX Basic System Vars
;; Some of them will be mapped over Sinclair ROM ones for compatibility
Expand All @@ -63,24 +63,24 @@ _screenAttributes2__leave:
SCREEN_ADDR: DW 16384 ; Screen address (can be pointed to other place to use a screen buffer)
SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.)
; These are mapped onto ZX Spectrum ROM VARS
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TVFLAGS EQU 23612 ; TV Flags
UDG EQU 23675 ; Pointer to UDG Charset
CHARS EQU 23606 ; Pointer to ROM/RAM Charset
TV_FLAG EQU 23612 ; Flags for controlling output to screen
UDG EQU 23675 ; Pointer to UDG Charset
COORDS EQU 23677 ; Last PLOT coordinates
FLAGS2 EQU 23681 ;
FLAGS2 EQU 23681 ;
ECHO_E EQU 23682 ;
DFCC EQU 23684 ; Next screen addr for PRINT
DFCCL EQU 23686 ; Next screen attr for PRINT
S_POSN EQU 23688
ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
ATTR_T EQU 23695 ; temporary ATTRIBUTES
P_FLAG EQU 23697 ;
MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars
SCR_COLS EQU 33 ; Screen with in columns + 1
SCR_ROWS EQU 24 ; Screen height in rows
SCR_SIZE EQU (SCR_ROWS << 8) + SCR_COLS
pop namespace
#line 5 "/zxbasic/src/arch/zx48k/library-asm/bright.asm"
#line 5 "/zxbasic/src/lib/arch/zx48k/runtime/bright.asm"
push namespace core
BRIGHT:
ld hl, ATTR_P
Expand Down Expand Up @@ -114,8 +114,8 @@ BRIGHT_TMP:
jr __SET_BRIGHT
ENDP
pop namespace
#line 33 "zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm"
#line 33 "arch/zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/cls.asm"
;; Clears the user screen (24 rows)
push namespace core
CLS:
Expand Down Expand Up @@ -145,8 +145,8 @@ CLS:
ret
ENDP
pop namespace
#line 34 "zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm"
#line 34 "arch/zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/ink.asm"
; Sets ink color in ATTR_P permanently
; Parameter: Paper color in A register
push namespace core
Expand Down Expand Up @@ -182,8 +182,8 @@ INK_TMP:
jp __SET_INK
ENDP
pop namespace
#line 35 "zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm"
#line 35 "arch/zx48k/attr_in_subs.bas"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/paper.asm"
; Sets paper color in ATTR_P permanently
; Parameter: Paper color in A register
push namespace core
Expand Down Expand Up @@ -222,5 +222,5 @@ PAPER_TMP:
jp __SET_PAPER
ENDP
pop namespace
#line 36 "zx48k/attr_in_subs.bas"
#line 36 "arch/zx48k/attr_in_subs.bas"
END
Loading

0 comments on commit c66077e

Please sign in to comment.