Posts: 806
Threads: 135
Joined: Apr 2009
Reputation:
5
I've added a partial clear screen routine (clearBox.bas) to the library. It does what it says - clears a defined rectangle of the screen. Good for clearing out the bits you don't want, such as the game board, but leave the status bit alone.
<!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:ClearBox">http://www.boriel.com/wiki/en/index.php ... C:ClearBox</a><!-- m -->
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
This comes very handy.
Just a little request: If you make comments in Assembly, please do not use the ";" character, but the sequence ";' " because as you can see, the syntax highlighter of the Wiki (and BorIDE) highlighs some comment words as keywords. Using the sequence prevents it from highlighting them. This is just a cosmetic issue.
Posts: 806
Threads: 135
Joined: Apr 2009
Reputation:
5
Bit ugly, but I see the logic. I still maintain it's a fail on the part of those bits of software, though
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
britlion Wrote:Bit ugly, but I see the logic. I still maintain it's a fail on the part of those bits of software, though  In fact the lexer does not know what is Assembler and what is BASIC. Standard lexers can recognise only one syntax, and ZX BASIC has two types of REM characters, which confuse ANY lexer. So the only solution is to use this sequenze in ASM.
Talking about it: ASM command SUB opens also a fold point in BorIDE, so I'm not a fan of using same keywords for BASIC as they are used by Assembler. Instead of SUB I would use PROCEDURE or PROC.
Posts: 1,838
Threads: 56
Joined: Aug 2019
Reputation:
25
The ZX BASIC lexer uses the Regular Expression:
Code: ([']|[Rr][Ee][Mm][ \t])
to match a comment line.
The ASM / END ASM sequence is a bit special (the lexer enters another state which I guess simple syntax-highlighters doesn't do).
Posts: 615
Threads: 49
Joined: Feb 2009
Reputation:
2
boriel Wrote:The ZX BASIC lexer uses the Regular Expression:
Code: ([']|[Rr][Ee][Mm][ \t])
to match a comment line.
The ASM / END ASM sequence is a bit special (the lexer enters another state which I guess simple syntax-highlighters doesn't do). Yes, thats what I mean. It is something special as ";" has a different meaning in BASIC than ASM.
Can you add the ability to recognise '-REM char also in Assembly blocks too? I know that it is used in EX AF,AF' too... Now it produces illegal character error.
Posts: 2
Threads: 1
Joined: Feb 2013
Reputation:
0
I've expanded the routine so it can also save and restore portions of the screen:
Code: CLS
FOR n=1 TO 300
PRINT n;
NEXT n
screenBox(2,3,18,11,2,35000)
pause 0
screenBox (2,3,18,11,1,35000)
pause 0
cls
screenBox (3,11,18,11,3,35000)
screenBox (4,9,18,11,3,35000)
pause 0
end
SUB screenBox(x AS UBYTE, y AS UBYTE, width AS UBYTE, height AS UBYTE, mode AS ubyte, address AS uinteger)
ASM
push de
ld d, (ix+15)
ld e, (ix+14)
ld (counter),de
ld a, (IX+13)
ld (modeflag),a
pop de
ld b,(IX+5)
ld c,(IX+7)
ld a, c
AND 24
OR 64
ld h, a
ld a, c
AND 7
rra
rra
rra
rra
add a, b
ld l, a
ld b, (IX+11)
ld c,(IX+9)
resbox_outer_loop:
XOR a
push bc
push hl
ld d, 8
resbox_mid_loop:
ld e,l
ld b,c
ld a,(modeflag)
sub 2
jp z,saveMode
ld a,(modeflag)
sub 3
jp z,restoreMode
ld a,0
clearMode:
ld (hl),a
inc l
djnz clearMode
jp goOn
saveMode:
push de
ld de, (counter)
saveBox_inner_loop:
ld a,(hl)
ld (de),a
inc l
inc de
djnz saveBox_inner_loop
ld (counter),de
pop de
jp goOn
restoreMode:
push de
ld de, (counter)
resbox_inner_loop:
ld a,(de)
ld (hl),a
inc l
inc de
djnz resbox_inner_loop
ld (counter),de
pop de
goOn:
ld l,e
inc h
dec d
jp nz, resbox_mid_loop
pop hl
pop bc
ld a, 32
add a, l
ld l, a
jp nc, resbox_row_skip
ld a, 8
add a, h
ld h, a
resbox_row_skip:
djnz resbox_outer_loop
END ASM
END SUB
ASM
counter:
defb 000,000
modeflag:
defb 000
end asm
It adds 2 new parameters: mode (1=clear, 2=save, 3=restore) and address (where the data will be saved to/restore from)
Cheers!
|