Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
As BorIDE progresses...
It did!! See now https://zxbasic.readthedocs.io/en/latest/if/
Basically, for the ELSEIF (compound if), there must be a new line after THEN.
This is because ZX BASIC now allows no END IF for single line ones!! (yes, like classic BASIC).
See: <!-- w --><a class="postlink" href="http://www.boriel.com/forum/post6091.html#p6091">www.boriel.com/forum/post6091.html#p6091</a><!-- w -->
Reply
Oh I understand. This explains a lot. Excellent!
Also now the output stream shows warning and errors with paths. That's why the errors are not marked in Source anymore. I will fix that code.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
Still have some Traceback errors ...
Code:
Traceback (most recent call last):
  File "D:\Restliche Programme\zxbasic\zxb.py", line 339, in <module>
    sys.exit(main())  # Exit
  File "D:\Restliche Programme\zxbasic\zxb.py", line 244, in main
    debug=(OPTIONS.Debug.value > 2))
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 328, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 820, in parseopt
    p.callable(pslice)
  File "D:\Restliche Programme\zxbasic\zxbparser.py", line 2461, in p_addr_of_id
    entry.accessed = True
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 39, in accessed
    for entry in self.scope_owner:
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 44, in scope_owner
    return list(self._scope_owner)
AttributeError: 'SymbolLABEL' object has no attribute '_scope_owner'
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
This looks like a compiler bug :!:
The code that produces it is the one posted above??
Reply
boriel Wrote:This looks like a compiler bug :!:
The code that produces it is the one posted above??
No, it is different, the upper code (Full code below) of the earlier prigram produces this:
Code:
Traceback (most recent call last):
  File "D:\Restliche Programme\zxbasic\zxb.py", line 339, in <module>
    sys.exit(main())  # Exit
  File "D:\Restliche Programme\zxbasic\zxb.py", line 287, in main
    asm_output = optimize(asm_output) + '\n'
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 2326, in optimize
    x.optimize()
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 1982, in optimize
    regs.op(i1, o1)
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 693, in op
    self.inc(o[0])
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 558, in inc
    v_ = self.getv(self.mem.get(r_, None))
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 516, in getv
    v = self.get(r)
  File "D:\Restliche Programme\zxbasic\arch\zx48k\optimizer.py", line 498, in get
    if r.lower() == '(sp)' and self.stack:
AttributeError: 'NoneType' object has no attribute 'lower'

Here it is:
Code:
dim control$,key$ as string
dim posx,posy,dir,drw,found as byte
dim shtx,shty,shard as Uinteger


poke uinteger 23675,@UDGs01

sub waitnokey()
    while inkey$<>"":wend
end sub
sub Drawscreen()
    dim x,y,byt as ubyte
    dim adr as uinteger
    dim a$ as string
    adr=@Buffer
    for y=0 to 21
        a$=""
        for x=0 to 31
            byt=peek adr
            if byt=0 then a$=a$+" ":else a$=a$+"\a":end If
            adr=adr+1
        next x
        print at y,0;ink 4;a$;
    next y
end sub
function Piece(x as Uinteger,y as Uinteger)
    dim b as uinteger
    dim a$ as string
    b=@Buffer+(y<<5)+x
    if peek b=0 then
        a$=" "
    elseif peek b=1 then
        a$="\{i4}\a"
    elseif peek b=2 then
        a$="\{i5}\g"
    elseif peek b=3 then
        a$="\{i5}\h"
    end if
    print at y,x;a$;
end function
sub PlacePiece(x as uinteger,y as Uinteger,piece as ubyte)
    poke @Buffer+(y<<5)+x,piece
end sub
function GetPiece(x as uinteger,y as Uinteger) as ubyte
    return @Buffer+(y<<5)+x
end Function
sub PlaceShards(cnt as integer)
    dim dir,dir1 as ubyte
    dim xy as uinteger
    while cnt>0
        xy=int(rnd*704)
        if peek(@Buffer+xy)=1 then
            cnt=cnt-1
            dir=int(rnd*1.99)
            if dir=1 then
                dir1=2
            else
                dir1=3
            end If
            poke @Buffer+xy,dir1
        end If
    wend

end sub



border 1:paper 0:bright 0:ink 7:Flash 0:Inverse 0:cls
print at 0,0;"\{b1}\{p1}Inu Yasha-Test  by LCD";

print at 3,1;"1. Keyboard QAOPM";
print at 4,1;"2. Sinclair 67890";

control$=""
while control$=""
    key$=inkey$
    if key$="1" then control$="qaopm":end If
    if key$="2" then control$="98670":end If
wend

randomize
cls

PlaceShards(32)
Drawscreen()

posx=10:posy=20


print at posy,posx;"\{i7}\j";
mainloop:
while key$<>control$(4)
    key$=inkey$
    if key$=control$(0) and posy>0 then Piece(posx,posy):posy=posy-1:print at posy,posx;"\{i7}\j";:waitnokey():end If
    if key$=control$(1) and posy<21 then Piece(posx,posy):posy=posy+1:print at posy,posx;"\{i7}\j";:waitnokey():end If
    if key$=control$(2) and posx>0 then Piece(posx,posy):posx=posx-1:print at posy,posx;"\{i7}\j";:waitnokey():end If
    if key$=control$(3) and posx<31 then Piece(posx,posy):posx=posx+1:print at posy,posx;"\{i7}\j";:waitnokey():end If
wend
if key$=control$(4) then
    print at 22,0;"\{p6}\{i2}\{b1}Select firing direction";
    print at 23,0;"\{p6}\{i2}\{b1}SPC to purify and get Shard";
    waitnokey()
    dir=0
    while dir=0
        key$=inkey$
        waitnokey()
        if key$=control$(0) then dir=1:end if
        if key$=control$(1) then dir=2:end if
        if key$=control$(2) then dir=3:end if
        if key$=control$(3) then dir=4:end if
        if key$=" " then
            found=0
            if GetPiece(posx+1,posy)>1 then found=found+1:shard=shard+1:PlacePiece(posx+1,posy,1):end If
            if GetPiece(posx-1,posy)>1 then found=found+1:shard=shard+1:PlacePiece(posx-1,posy,1):end If
            if GetPiece(posx,posy-1)>1 then found=found+1:shard=shard+1:PlacePiece(posx,posy-1,1):end If
            if GetPiece(posx,posy+1)>1 then found=found+1:shard=shard+1:PlacePiece(posx,posy+1,1):end If
            if found=0 then border 2:pause 5:border 0:end if
            dir=5
        end if


    wend
    if dir=5 then dir=0:end if
    print at 22,0;"\{p0}\{i7}\{b0}                       ";
    print at 23,0;"\{p0}\{i7}\{b0}                           ";
    shtx=posx
    shty=posy
    while dir>0
        if dir=1 and shty>0 then shty=shty-1:end if
        if dir=2 and shty<22 then shty=shty+1:end if
        if dir=3 and shtx>0 then shtx=shtx-1:end if
        if dir=4 and shtx<31 then shtx=shtx+1:end if
        bg=peek(@Buffer+(shty<<5)+shtx)
        if bg=2 then dir=peek(@Shoottable1+dir-1):end If
        if bg=3 then dir=peek(@Shoottable2+dir-1):end if
        if shtx=0 or shtx=31 or shty=0 or shty=22 then dir=0:end If
        'if bg<99 then
        if bg=0 then
            drw=1
        else
            drw=0
        end if
        if drw then
        print at shty,shtx;"*";
        end if
    wend
end if
goto mainloop

End
Shoottable1:
asm
    defb 4,3,2,1 ;/
end asm
Shoottable2:
asm
    defb 3,4,1,2 ;\
end asm
UDGs01:
asm
    defb 24, 44, 94, 60, 24, 24, 60,  0 ;A Tree
    defb 16, 56, 16, 16, 16, 16, 56, 40 ;B Arrow up
    defb  0,  0,  0,194,127,194,  0,  0 ;C Arrow right
    defb 40, 56, 16, 16, 16, 16, 56, 16 ;D Arrow down
    defb  0,  0,  0, 67,254, 67,  0,  0 ;E Arrow left
    defb 16, 42, 84, 40, 16,  8, 20,  0 ;F Tree Visited
    defb  0,  2, 12, 28, 56, 48, 64,  0    ;G Shard /
    defb  0, 64, 48, 56, 28, 12,  2,  0 ;H Shard \
    defb 24, 24, 60, 60, 90, 24, 60, 36 ;I Youkai
    DEFB  0, 24, 24, 60, 90, 24, 36, 36    ;J Figure
end asm
Buffer:
asm
    DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0
    DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
end asm
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
Ok. This seems to be with -O3. Using -O2 or lower should give no problems.
Reply
boriel Wrote:Ok. This seems to be with -O3. Using -O2 or lower should give no problems.
That's true.
Today I made a big progress with BorIDE. Custom loader (Counter Load) works also too. Hope to release it soon.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
LCD Wrote:Today I made a big progress with BorIDE. Custom loader (Counter Load) works also too. Hope to release it soon.
Great!!! Tongue
BTW I'm going to add a zxbasic "check only" mode, which just outputs errors but does nothing else (e.g. zxb --check) useful for editors and normally faster.
Reply
boriel Wrote:
LCD Wrote:Today I made a big progress with BorIDE. Custom loader (Counter Load) works also too. Hope to release it soon.
Great!!! Tongue
BTW I'm going to add a zxbasic "check only" mode, which just outputs errors but does nothing else (e.g. zxb --check) useful for editors and normally faster.
Sounds like agreat addition. Currently I deactivated the Debug mode, but forgot why.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
Oh, Found a bug, I think:
Code:
Traceback (most recent call last):
  File "D:\Restliche Programme\zxbasic\zxb.py", line 339, in <module>
    sys.exit(main())  # Exit
  File "D:\Restliche Programme\zxbasic\zxb.py", line 244, in main
    debug=(OPTIONS.Debug.value > 2))
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 328, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 820, in parseopt
    p.callable(pslice)
  File "D:\Restliche Programme\zxbasic\zxbparser.py", line 2461, in p_addr_of_id
    entry.accessed = True
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 39, in accessed
    for entry in self.scope_owner:
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 44, in scope_owner
    return list(self._scope_owner)
AttributeError: 'SymbolLABEL' object has no attribute '_scope_owner'
That was without optimizer, in this code:
Code:
dim tiles(16) as uinteger
tiles(0)=@void
tiles(1)=@Sea
tiles(2)=@Bridge
tiles(3)=@Park
tiles(4)=@Schutt
tiles(5)=@skyscraper

tiles(6)=@car
tiles(7)=@PoliceCar
tiles(8)=@People
tiles(9)=@house

dim monstergfx(5,1,3) as uinteger
dim directionstring$(3) as string
directionstring$(0)="NORTH"
directionstring$(1)="WEST "
directionstring$(2)="SOUTH"
directionstring$(3)="EAST "

dim winddir,headingdir,headdir as byte
dim monsterx,monstery as byte
dim alt as ubyte
goto start
buffer:
asm
    defs 3360
end asm
mapSF: '1024 bytes
asm
    DEFB     05,00,05,00,05,00,09,00,    00,00,01,01,01,01,01,03,    00,00,05,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     09,00,09,00,09,00,09,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     03,00,09,09,00,03,09,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     03,00,09,00,09,00,09,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     03,00,09,00,09,00,03,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,03,00,09,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
                    
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
                    
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
                    
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
    DEFB     00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00,    00,00,00,00,00,00,00,00
end asm

void:
asm
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
    DEFB 0,0,0,0,0,0,0,0
end asm

People: '3x3
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    014,015,014,006,007,007,015,006
    DEFB    015,031,063,062,007,006,006,014
    DEFB    000,000,000,000,000,000,000,000
    DEFB    004,131,193,000,000,003,004,006
    DEFB    002,131,193,034,192,064,000,000
    DEFB    000,000,000,000,224,224,224,096
    DEFB    248,102,108,096,096,224,048,024
    DEFB    012,006,002,004,000,000,000,000
end asm
skyscraper: '3x3
asm
    DEFB    000,000,000,000,031,063,127,254
    DEFB    170,171,254,170,171,254,170,171
    DEFB    254,170,170,255,170,171,255,254
    DEFB    003,004,009,019,255,167,063,103
    DEFB    191,039,127,167,063,103,191,039
    DEFB    127,167,063,103,255,167,063,063
    DEFB    192,192,192,192,192,255,193,131
    DEFB    253,093,093,093,093,093,093,093
    DEFB    093,093,093,093,093,093,094,252
end asm
Park: '3x3
asm
    DEFB    000,001,009,053,060,024,115,121
    DEFB    061,246,018,003,001,000,000,048
    DEFB    120,124,124,056,016,016,255,000
    DEFB    000,128,192,192,112,160,240,120
    DEFB    076,092,096,240,168,128,128,128
    DEFB    128,132,159,159,156,132,255,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    048,124,124,124,092,017,255,000
end asm
Schutt: '3x3
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,001,007
    DEFB    030,061,111,245,119,007,001,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,028,187,119
    DEFB    235,253,159,231,251,221,190,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,192
    DEFB    160,184,220,103,190,216,000,000
end asm
PoliceCar: '3x3
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,001,002,004,115
    DEFB    255,248,243,228,004,003,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,028,020,255,000,000,255
    DEFB    129,065,066,165,189,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,128,128,064,224
    DEFB    254,031,207,039,036,192,000,000
end asm
Bridge:
asm
    DEFB    255,153,096,237,237,236,094,191
    DEFB    191,109,204,172,109,012,255,012
    DEFB    255,255,012,141,237,140,191,192
    DEFB    254,231,031,249,231,030,255,126
    DEFB    030,129,203,102,189,000,255,000
    DEFB    255,255,000,231,255,126,102,126
    DEFB    127,249,134,183,183,048,123,253
    DEFB    253,182,051,053,182,048,255,048
    DEFB    255,255,048,176,183,049,252,001
end asm
Sea:
asm
    DEFB    255,051,252,207,243,252,255,060
    DEFB    255,207,060,255,207,243,252,207
    DEFB    063,252,207,063,255,243,060,255
    DEFB    252,207,063,243,207,060,255,255
    DEFB    060,195,255,255,207,063,252,243
    DEFB    255,252,051,207,255,243,207,063
    DEFB    255,243,012,255,255,240,015,255
    DEFB    243,255,051,207,252,255,255,051
    DEFB    204,255,255,049,207,255,241,063
end asm
car:
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,031
    DEFB    063,126,124,125,061,003,001,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,127,255,123,056,024,024,255
    DEFB    255,063,030,222,094,225,192,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,128,192,224,048,024,252
    DEFB    254,030,014,239,174,240,224,000
end asm
car1:
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    007,031,117,117,127,255,165,024
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    192,224,096,088,254,255,165,024
    DEFB    000,000,000,000,000,000,000,000
end asm

house:
asm
    DEFB    003,103,111,127,127,255,085,042
    DEFB    065,034,065,042,000,031,063,127
    DEFB    253,223,027,027,027,031,000,000
    DEFB    000,128,192,224,240,248,080,160
    DEFB    016,039,023,039,006,255,255,255
    DEFB    085,255,007,119,119,119,000,000
    DEFB    000,000,000,000,008,060,062,255
    DEFB    127,073,073,127,127,248,254,255
    DEFB    127,247,050,050,052,248,000,000
end asm
faxctory:
asm
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,000,002,007,015,031,063,127
    DEFB    255,106,106,110,110,110,127,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,001,001,001,129,193,227,243
    DEFB    255,170,187,187,170,170,255,000
    DEFB    000,000,000,000,000,000,000,000
    DEFB    000,152,152,152,152,152,252,252
    DEFB    255,171,187,187,171,171,255,000

end asm
infantry:
asm
    DEFB    255,255,255,255,255,255,255,255
    DEFB    249,249,249,224,208,176,176,177
    DEFB    129,208,178,242,230,206,158,142
    DEFB    255,255,255,252,250,246,246,246
    DEFB    224,218,182,062,188,121,243,241
    DEFB    255,255,127,127,127,127,127,127
    DEFB    061,059,051,011,023,015,063,063
    DEFB    031,015,079,079,207,207,207,199
    DEFB    255,255,255,255,255,255,255,255
end asm
helicopter:
asm
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,159,064,035,156,255,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,255,255,000,000,254
    DEFB    248,247,239,015,239,111,143,247
    DEFB    248,251,245,192,255,255,255,255
    DEFB    255,255,255,255,255,000,000,127
    DEFB    031,015,007,007,007,247,247,239
    DEFB    031,223,235,007,255,255,255,255
end asm
police2:
asm
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,254,253,192,128,173,243,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,255,255,255,255,239
    DEFB    215,001,238,016,056,017,255,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,003,001,107,159,255
    DEFB    255,255,255,255,255,255,255,255
end asm

civilans:
asm
    DEFB    255,255,255,255,255,255,227,224
    DEFB    226,243,241,241,225,243,225,192
    DEFB    128,131,240,243,243,227,255,255
    DEFB    255,255,254,254,254,255,246,249
    DEFB    125,255,255,248,247,243,251,249
    DEFB    125,187,127,127,255,255,255,255
    DEFB    255,255,063,063,063,063,015,051
    DEFB    039,063,063,063,159,207,231,243
    DEFB    251,247,255,255,255,255,255,255
end asm

civcar:
asm
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,252,252,252,248,250,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    193,000,084,085,000,000,210,063
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,255,255,255,255,255
    DEFB    255,255,255,063,015,007,215,063
    DEFB    255,255,255,255,255,255,255,255
end asm

park:
asm
    DEFB    255,255,255,255,255,255,255,255
    DEFB    008,042,170,170,170,170,170,170
    DEFB    042,028,028,028,028,028,028,062
    DEFB    255,255,255,255,255,255,255,255
    DEFB    000,000,128,128,128,128,160,160
    DEFB    112,168,113,171,115,171,115,249
    DEFB    255,255,255,255,255,255,255,255
    DEFB    000,000,000,008,008,028,008,028
    DEFB    042,028,042,156,170,136,156,062
end asm


fire:
asm
    DEFB    000,000,000,000,032,016,016,016
    DEFB    024,030,014,003,003,007,007,015
    DEFB    014,027,027,051,251,255,127,063
    DEFB    000,000,000,000,000,000,016,048
    DEFB    032,032,104,076,196,134,003,003
    DEFB    003,135,199,225,225,115,247,255
    DEFB    000,000,128,192,068,196,068,068
    DEFB    108,014,012,028,028,028,030,028
    DEFB    028,190,246,254,094,015,254,254

end asm

GoshiraL1:
asm
    DEFB    255,255,255,255,255,255,254,255
    DEFB    254,255,254,255,240,239,216,182
    DEFB    113,117,109,158,254,254,255,255
    DEFB    254,253,251,243,138,085,132,069
    DEFB    146,096,164,069,194,087,103,035
    DEFB    028,087,179,241,251,253,110,118
    DEFB    239,119,023,123,043,091,247,239
    DEFB    239,119,051,125,186,187,187,254
    DEFB    177,091,205,197,173,245,237,219
end asm
GoshiraL2:
asm
    DEFB    255,255,255,255,255,255,254,255
    DEFB    254,255,254,255,240,239,216,182
    DEFB    113,117,109,158,254,254,255,255
    DEFB    254,253,251,243,138,085,132,069
    DEFB    146,096,164,069,194,087,103,035
    DEFB    028,087,179,241,251,253,110,118
    DEFB    239,119,023,123,043,091,247,239
    DEFB    239,119,051,125,186,187,187,254
    DEFB    177,091,205,197,173,245,237,219

    DEFB    255,255,255,255,255,255,253,253
    DEFB    248,252,252,241,240,254,254,253
    DEFB    252,253,252,191,159,166,200,225
    DEFB    255,252,250,245,202,212,152,102
    DEFB    175,109,078,087,009,023,171,016
    DEFB    040,148,170,092,042,085,171,103
    DEFB    063,063,159,079,191,255,127,127
    DEFB    127,127,255,127,191,127,255,127
    DEFB    127,063,063,095,159,079,175,143
end asm
GoshiraD1:
asm
    DEFB    255,255,255,255,255,255,254,253
    DEFB    254,253,225,159,108,125,231,235
    DEFB    219,059,251,251,251,251,251,247
    DEFB    239,223,208,189,170,055,191,047
    DEFB    170,079,157,165,247,255,202,194
    DEFB    039,063,031,063,253,250,247,247
    DEFB    191,223,095,239,175,103,235,165
    DEFB    171,149,205,046,121,253,159,030
    DEFB    037,230,198,230,254,254,126,127
end asm
GoshiraR1:
ASM
    DEFB    247,239,232,222,212,219,239,247
    DEFB    247,238,206,191,093,221,223,127
    DEFB    143,219,179,183,191,191,191,223
    DEFB    127,191,223,199,088,171,161,162
    DEFB    073,070,047,162,075,255,230,197
    DEFB    058,235,205,223,255,255,126,126
    DEFB    255,255,255,255,255,127,127,255
    DEFB    127,255,127,255,015,247,027,109
    DEFB    142,174,182,121,127,127,255,255
end asm
GoshiraU1:
asm
    DEFB    255,255,255,254,254,252,250,253
    DEFB    250,253,250,244,234,235,239,247
    DEFB    240,244,244,244,247,247,247,239
    DEFB    190,127,065,193,170,085,170,000
    DEFB    042,000,008,000,171,001,130,004
    DEFB    012,017,147,247,255,239,209,221
    DEFB    255,127,127,191,191,031,175,095
    DEFB    047,095,047,247,027,045,125,126
    DEFB    238,246,177,183,247,247,247,251
end asm

SquidL1:
asm
    DEFB    024,024,024,024,056,056,120,120
    DEFB    120,240,240,240,240,120,124,062
    DEFB    031,031,015,003,001,135,127,127
    DEFB    000,048,060,062,062,127,255,255
    DEFB    245,245,255,255,255,255,126,062
    DEFB    127,255,255,255,255,255,255,128
    DEFB    000,000,000,003,015,015,015,014
    DEFB    142,143,143,143,143,015,014,014
    DEFB    142,254,254,252,252,000,254,031
end asm

title: '30x14, compressed
asm
    DEFB    000,199,001,007,143,028,056,181
    DEFB    120,079,255,248,255,252,124,062
    DEFB    251,030,031,007,003,000,005,068
    DEFB    255,255,125,192,128,136,061,234
    DEFB    128,144,223,255,130,163,144,252
    DEFB    255,145,015,052,236,001,199,235
    DEFB    001,003,015,216,255,254,042,175
    DEFB    031,128,039,255,028,002,006,015
    DEFB    222,030,014,255,254,142,134,143
    DEFB    015,063,127,000,193,117,255,056
    DEFB    143,252,030,178,008,022,121,192
    DEFB    011,174,145,254,126,060,145,255
    DEFB    028,204,252,062,115,252,031,216
    DEFB    007,002,046,191,144,127,063,031
    DEFB    015,014,030,040,252,255,031,063
    DEFB    111,206,216,140,008,046,188,144
    DEFB    001,002,004,012,124,006,003,016
    DEFB    029,241,180,189,008,012,015,004
    DEFB    134,072,186,003,247,007,030,078
    DEFB    074,071,255,121,116,156,152,106
    DEFB    239,209,252,012,159,057,149,224
    DEFB    112,056,136,027,024,017,176,227
    DEFB    189,148,031,241,063,248,240,128
    DEFB    217,158,116,143,192,240,236,242
    DEFB    123,031,149,237,240,038,255,112
    DEFB    255,048,039,120,121,115,222,119
    DEFB    124,244,160,120,241,027,248,252
    DEFB    012,123,053,001,098,127,199,044
    DEFB    232,076,209,124,038,056,028,014
    DEFB    015,113,099,006,187,165,236,083
    DEFB    133,239,144,129,243,247,241,075
    DEFB    085,016,083,153,211,131,016,055
    DEFB    225,216,227,199,255,215,052,034
    DEFB    255,129,006,205,247,093,007,015
    DEFB    025,225,057,048,001,097,012,024
    DEFB    133,096,078,255,051,062,012,204
    DEFB    090,224,224,032,255,096,125,240
    DEFB    243,231,238,248,235,244,240,214
    DEFB    241,248,060,144,075,215,192,017
    DEFB    226,025,253,114,224,144,255,236
    DEFB    236,252,124,088,192,124,215,112
    DEFB    056,028,030,113,099,012,132,150
    DEFB    255,062,026,243,197,008,025,248
    DEFB    059,124,248,056,024,194,152,032
    DEFB    120,224,027,255,124,023,226,013
    DEFB    249,252,219,140,112,132,037,251
    DEFB    236,207,012,007,052,117,144,192
    DEFB    240,124,194,240,074,037,013,044
    DEFB    073,024,105,072,224,204,048,024
    DEFB    036,014,175,253,002,243,118,214
    DEFB    048,224,073,229,133,090,112,095
    DEFB    062,241,047,125,112,224,241,192
    DEFB    064,133,129,096,057,216,031,014
    DEFB    163,146,004,012,247,029,062,124
    DEFB    028,007,108,092,079,113,104,133
    DEFB    154,112,211,048,112,255,096,032
    DEFB    005,027,248,117,194,206,237,248
    DEFB    124,126,197,028,144,096,248,190
    DEFB    142,117,095,036,235,022,012,188
    DEFB    021,193,115,092,112,048,124,223
    DEFB    142,172,129,253,146,140,165,150
    DEFB    250,159,011,122,112,059,043,030
    DEFB    062,153,035,134,142,035,041,034
    DEFB    029,143,152,206,252,028,232,014
    DEFB    058,048,164,081,215,112,056,126
    DEFB    230,220,131,001,255,071,244,061
    DEFB    249,131,230,126,056,130,158,172
    DEFB    112,001,148,255,129,120,193,244
    DEFB    192,255,142,128,253,150,059,253
    DEFB    009,250,112,091,239,102,156,255
    DEFB    144,017,221,184,030,248,089,253
    DEFB    159,208,095,066,226,014,031,062
    DEFB    187,195,175,251,030,158,206,142
    DEFB    009,182,192,195,223,035,171,255
    DEFB    189,174,006,119,152,171,046,060
    DEFB    144,024,062,111,135,162,149,253
    DEFB    071,145,001,075,246,207,005,108
    DEFB    149,040,159,231,183,252,030,103
    DEFB    124,027,189,252,246,195,176,231
    DEFB    084,094,145,192,255,093,127,003
    DEFB    220,254,031,247,225,120,244,251
    DEFB    252,193,243,223,206,005,117,033
    DEFB    015,113,160,254,077,199,131,195
    DEFB    143,227,115,231,065,097,099,248
    DEFB    135,015,176,031,086,179,017,110
    DEFB    120,158,192,195,134,140,252,028
    DEFB    031,156,227,255,158,143,246,135
    DEFB    195,225,011,214,016,235,224,248
    DEFB    028,206,104,216,089,056,030,248
    DEFB    246,240,010,182,016,096,016,000
end asm

' MegaLZ Unpacker by Britlion
SUB megaLZDepack(source as uInteger,dest as uInteger)
ASM

LD E,(IX+6)
LD D,(IX+7)

;'Z80 depacker for megalz V4 packed files   (C) fyrex^mhm

;' DESCRIPTION:
;'
;' Depacker is fully relocatable, not self-modifying,
;'it's length is 110 bytes starting from DEC40.
;'Register usage: AF,AF',BC,DE,HL. Must be CALL'ed, return is done by RET.
;'Provide extra stack location for store 2 bytes (1 word). Depacker does not
;'disable or enable interrupts, as well as could be interrupted at any time
;'(no f*cking wicked stack usage :).

;' USAGE:
;'
;' - put depacker anywhere you want,
;' - put starting address of packed block in HL,
;' - put location where you want data to be depacked in DE,
;'   (much like LDIR command, but without BC)
;' - make CALL to depacker (DEC40).
;' - enjoy! ;)

;' PRECAUTIONS:
;'
;' Be very careful if packed and depacked blocks coincide somewhere in memory.
;'Here are some advices:
;'
;' 1. put packed block to the highest addresses possible.
;'     Best if last byte of packed block has address #FFFF.
;'
;' 2. Leave some gap between ends of packed and depacked block.
;'     For example, last byte of depacked block at #FF00,
;'     last byte of packed block at #FFFF.
;'
;' 3. Place nonpackable data to the end of block.
;'
;' 4. Always check whether depacking occurs OK and neither corrupts depacked data
;'     nor hangs computer.
;'

;'DEC40

        LD      A,80h
        EX      AF,AF'
MS:     LDI
M0:      LD      BC,2FFh
M1:      EX      AF,AF'
M1X:     ADD     A,A
        JR      NZ,M2
        LD      A,(HL)
        INC     HL
        RLA
M2:      RL      C
        JR      NC,M1X
        EX      AF,AF'
        DJNZ    X2
        LD      A,2
        SRA     C
        JR      C,N1
        INC     A
        INC     C
        JR      Z,N2
        LD      BC,33Fh
        JR      M1

X2:      DJNZ    X3
        SRL     C
        JR      C,MS
        INC     B
        JR      M1
X6:
        ADD     A,C
N2:
        LD      BC,4FFh
        JR      M1
N1:
        INC     C
        JR      NZ,M4
        EX      AF,AF'
        INC     B
N5:      RR      C
        JP     C, END_DEC40
        RL      B
        ADD     A,A
        JR      NZ,N6
        LD      A,(HL)
        INC     HL
        RLA
N6:      JR      NC,N5
        EX      AF,AF'
        ADD     A,B
        LD      B,6
        JR      M1
X3:
        DJNZ    X4
        LD      A,1
        JR      M3
X4:      DJNZ    X5
        INC     C
        JR      NZ,M4
        LD      BC,51Fh
        JR      M1
X5:
        DJNZ    X6
        LD      B,C
M4:      LD      C,(HL)
        INC     HL
M3:      DEC     B
        PUSH    HL
        LD      L,C
        LD      H,B
        ADD     HL,DE
        LD      C,A
        LD      B,0
        LDIR
        POP     HL
        JR      M0
      
      
END_DEC40:

END ASM
END SUB
sub wait(frames as ubyte)
    dim a as ubyte
    for a=0 to frames
        asm
            halt
        end asm
    next a
end sub
SUB paint (x as uByte,y as uByte, width as uByte, height as uByte, attribute as ubyte)
  asm
    ld      a,(IX+7)   ;'ypos
    rrca
    rrca
    rrca               ;' Multiply by 32
    ld      l,a        ;' Pass to L
    and     3          ;' Mask with 00000011
    add     a,88       ;' 88 * 256 = 22528 - start of attributes. Change this if you are working with a buffer or somesuch.
    ld      h,a        ;' Put it in the High Byte
    ld      a,l        ;' We get y value *32
    and     224        ;' Mask with 11100000
    ld      l,a        ;' Put it in L
    ld      a,(IX+5)   ;' xpos
    add     a,l        ;' Add it to the Low byte
    ld      l,a        ;' Put it back in L, and we're done. HL=Address.

    push HL            ;' save address
    LD A, (IX+13)      ;' attribute
    LD DE,32
    LD c,(IX+11)       ;' height

    BLPaintHeightLoop:
    LD b,(IX+9)        ;' width

    BLPaintWidthLoop:
    LD (HL),a          ;' paint a character
    INC L              ;' Move to the right (Note that we only would have to inc H if we are crossing from the right edge to the left, and we shouldn't be needing to do that)
    DJNZ BLPaintWidthLoop

    BLPaintWidthExitLoop:
    POP HL             ;' recover our left edge
    DEC C
    JR Z, BLPaintHeightExitLoop

    ADD HL,DE          ;' move 32 down
    PUSH HL            ;' save it again
    JP BLPaintHeightLoop

    BLPaintHeightExitLoop:

  end asm
END SUB
SUB paintData (x as uByte,y as uByte, width as uByte, height as uByte, address as uInteger)
  asm
    ld      a,(IX+7)   ;'ypos
    rrca
    rrca
    rrca               ;' Multiply by 32
    ld      l,a        ;' Pass to L
    and     3          ;' Mask with 00000011
    add     a,88       ;' 88 * 256 = 22528 - start of attributes. Change this if you are working with a buffer or somesuch.
    ld      h,a        ;' Put it in the High Byte
    ld      a,l        ;' We get y value *32
    and     224        ;' Mask with 11100000
    ld      l,a        ;' Put it in L
    ld      a,(IX+5)   ;' xpos
    add     a,l        ;' Add it to the Low byte
    ld      l,a        ;' Put it back in L, and we're done. HL=Address.

    push HL            ;' save address
    LD D, (IX+13)
    LD E, (IX+12)
    LD c,(IX+11)       ;' height

    BLPaintDataHeightLoop:
    LD b,(IX+9)        ;' width

    BLPaintDataWidthLoop:
    LD a,(DE)
    LD (HL),a          ;' paint a character
    INC L              ;' Move to the right (Note that we only would have to inc H if we are crossing from the right edge to the left, and we shouldn't be needing to do that)
    INC DE
    DJNZ BLPaintDataWidthLoop

    BLPaintDataWidthExitLoop:
    POP HL             ;' recover our left edge
    DEC C
    JR Z, BLPaintDataHeightExitLoop
    PUSH DE
    LD DE,32
    ADD HL,DE          ;' move 32 down
    POP DE
    PUSH HL            ;' save it again
    JP BLPaintDataHeightLoop

    BLPaintDataHeightExitLoop:

  end asm
END SUB  
SUB putChars(x as uByte,y as uByte, width as uByte, height as uByte, dataAddress as uInteger)
  asm
    BLPutChar:
      LD      a,(IX+5)
      ;AND     31
      ld      l,a
      ld      a,(IX+7) ;' Y value
      ld      d,a
      AND     24
      add     a,64 ;' 256 byte "page" for screen - 256*64=16384. Change this if you are working with a screen address elsewhere, such as a buffer.
      ld      h,a
      ld      a,d
      AND     7
      rrca
      rrca
      rrca
      OR      l
      ld      l,a

      PUSH HL ;' save our address

      LD E,(IX+12) ;' data address
      LD D,(IX+13)
      LD B,(IX+9) ;' width
      PUSH BC ;' save our column count

      BLPutCharColumnLoop:

      LD B,(IX+11) ;' height

      BLPutCharInColumnLoop:
      
      ;' gets screen address in HL, and bytes address in DE. Copies the 8 bytes to the screen
      ld a,(DE) ;' First Row
      LD (HL),a
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' second Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Third Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Fourth Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Fifth Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Sixth Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Seventh Row
      
      INC DE
      INC H
      ld a,(DE)
      LD (HL),a ;' Eigth Row
      
      INC DE ;' Move to next data item.
      
      DEC B
      JR Z,BLPutCharNextColumn
      ;'The following code calculates the address of the next line down below current HL address.
      PUSH DE ;' save DE
      ld   a,l  
      and  224  
      cp   224  
      jp   z,BLPutCharNextThird

      BLPutCharSameThird:
                ld   de,-1760
                ;'and  a        
                add  hl,de    
        POP DE ;' get our data point back.
        jp BLPutCharInColumnLoop

      BLPutCharNextThird:
        ld   de,32    
        ;'and  a
        add  hl,de  
        POP DE ;' get our data point back.
        JP BLPutCharInColumnLoop

      BLPutCharNextColumn:
        POP BC
        POP HL
        DEC B
        JP Z, BLPutCharsEnd

        INC L   ;' Note this would normally be Increase HL - but block painting should never need to increase H, since that would wrap around.
        PUSH HL
        PUSH BC
        JP BLPutCharColumnLoop

            BLPutCharsEnd:
  end asm
END SUB
SUB clearBox(x AS UBYTE, y AS UBYTE, width AS UBYTE, height AS UBYTE)
' This subroutine will blank the pixels for a box, measured in Character Squares
' from print positions X,Y to X+Width, Y+height.
'
' Expected to be useful for clearing a window of space - perhaps in a game.
' because of this THE ERROR CHECKING IS NONEXISTENT.
' Please make sure you send sensible data -
' 0<x<32, 0<y<23, x+width<32 and y+height<23
' Britlion 2012.

ASM
    ld b,(IX+5)         ;' get x value
    ld c,(IX+7)        ;' get y value

    ld a, c        ;' Set HL to screen byte for this character.    
    AND 24        ;'   |
    OR 64        ;'   |
    ld h, a        ;'   |
    ld a, c        ;'   |
    AND 7        ;'   |
    rra        ;'   |
    rra        ;'   |
    rra        ;'   |
    rra        ;'   |
    add a, b    ;'   |
    ld l, a        ;'   v

    ld b, (IX+11)   ;' get height
    ld c,(IX+9)     ;' get width        

clearbox_outer_loop:
    XOR a
    push bc     ;' save height.
    push hl     ;' save screen address.
    ld d, 8     ;' 8 rows to a character.

    clearbox_mid_loop:
        ld e,l       ;' save screen byte lower half.
        ld b,c       ;' get width.

        clearbox_inner_loop: ld (hl), a    ;' write out a zero to the screen.
        inc l            ;' go right.
    djnz clearbox_inner_loop    ;' repeat.

        ld l,e       ;' recover screen byte
        inc h             ;' down a row

    dec d
    jp nz, clearbox_mid_loop  ;' repeat for this row.

    pop hl             ;' get back address at start of line
    pop bc             ;' get back char count.

    ld a, 32         ;' Go down to next character row.
    add a, l         ;'
    ld l, a              
    jp nc, clearbox_row_skip      

    ld a, 8              
    add a, h        
    ld h, a              

    clearbox_row_skip:

djnz clearbox_outer_loop
END ASM
END SUB
SUB BLWindowScrollUp(X AS UBYTE,Y AS UBYTE,Width AS UBYTE,Height AS UBYTE)
ASM
;'Routine FOR printing AND scrolling text in any
;'window, anywhere on the screen.

;'Main scrolling routine
BLWindowScrollUp:
EX AF, AF'
LD   A,(IX+11)  ;'(ROWS) Store # of Lines in A'
EX AF,AF'

LD   HL,BLWindowScrollUpScreenTable    ;'Start of address table
LD   C,(IX+7)   ;'(Y) Move the "pointer" TO the
LD   B,0         ;'appropriate position in the table
ADD  HL,BC       ;'and store it in (BLWindowScrollPOINT)
ADD  HL,BC
LD   (BLWindowScrollUpPOINT),HL  ;'Pointer position stored
BLWindowScrollUpLOOP:
    LD   HL,(BLWindowScrollUpPOINT)
    LD   E,(HL)
    INC  HL
    LD   D,(HL)

    ;'Address of start of screen line now in DE
    LD A,(IX+5) ;(X)
    ADD A,E
    LD E,A

    ;'Address of left-hand side of window now in DE
    EX AF,AF'
    DEC  A
    JP   Z,BLWindowScrollUpBLANK     ;'Quit this LOOP IF we have
    EX AF,AF'
    INC  HL          ;'Move the pointer TO the NEXT item
    LD   (BLWindowScrollUpPOINT),HL  ;'in the table. SAVE position
    LD   C,(HL)
    INC  HL
    LD   B,(HL)      ;'Start of NEXT line down in BC
    LD   L,(IX+5)    ;' (X)
    LD   H,0
    ADD  HL,BC
    ;'HL now points TO the screen address 8 pixels below
    ;'the one held in DE
    LD   B,8         ;'8 pixel lines TO be transferred
    ;'Now move 8 pixel lines up the screen by 8 pixels

    BLWindowScrollUpTRANS:
        LD A,B ; SAVE B
        LD   C,(IX+9) ;'(Cols)
        LD   B,0
        PUSH HL
        PUSH DE          ;'Save all registers
        LDIR             ;'Transfer the line of pixels
        POP  DE
        POP  HL

        ;'Move HL AND DE down one pixel
        INC D
        INC H

        LD B,A ;' Recover B

    DJNZ BLWindowScrollUpTRANS
    ;'One line of characters has now been transferred
JP   BLWindowScrollUpLOOP        ;'Back FOR NEXT line of characters

;'Scrolling finished. Now erase last character line
BLWindowScrollUpBLANK:
LD   C,8
LD   L,(IX+9) ;' (COLS)
BLWindowScrollUpLOOP2:
    PUSH DE    
    LD   B,L ;'(IX+11) - Cols
    XOR  A
    BLWindowScrollUpLOOP3:
        LD   (DE),A
        INC E
    DJNZ BLWindowScrollUpLOOP3
    POP  DE
    INC D
    DEC C
    JR NZ, BLWindowScrollUpLOOP2
;'DJNZ BLWindowScrollUpLOOP2
JP BLWindowScrollEnd


BLWindowScrollUpPOINT:  DEFW 0

BLWindowScrollUpScreenTable:
       DEFW 16384
       DEFW 16416
       DEFW 16448
       DEFW 16480
       DEFW 16512
       DEFW 16544
       DEFW 16576
       DEFW 16608
       DEFW 18432
       DEFW 18464
       DEFW 18496
       DEFW 18528
       DEFW 18560
       DEFW 18592
       DEFW 18624
       DEFW 18656
       DEFW 20480
       DEFW 20512
       DEFW 20544
       DEFW 20576
       DEFW 20608
       DEFW 20640
       DEFW 20672
       DEFW 20704
BLWindowScrollEnd:
END ASM
END SUB
sub waitkey()
    asm
    waitkey1:
        xor a
        in a,($fe)
        cpl
        and %00011111
        jr z,waitkey1
    end asm
end sub
sub WaitNoKey()
    asm
        waitnokey1:
        xor a
        in a,($fe)
        cpl
        and %00011111
        jr nz,waitnokey1
    end asm
end sub
sub CopyMem(src as Uinteger,des as Uinteger,length as Uinteger)
    poke uinteger @CopyMemory+1,src
    poke uinteger @CopyMemory+4,des
    poke uinteger @CopyMemory+7,length
    CopyMemory:
    asm
        ld hl,1
        ld de,2
        ld bc,3
        ldir
    end asm
end sub
sub FillMem(mem as Uinteger,size as Uinteger,byt as Ubyte)
    poke uinteger @FillMemory+1,mem
    poke @FillMemory+4,byt
    poke uinteger @FillMemory+6,mem+1
    poke uinteger @FillMemory+9,size-1
    FillMemory:
    asm
        ld hl,1
        ld (hl),2
        ld de,3
        ld bc,4
        ldir
    end asm
end sub
sub drawmap(x as ubyte,y as ubyte)
    dim x1,y1 as ubyte
    dim adr as Uinteger
    for y1=0 to 7
        adr=@buffer+x+(y+y1)*32
        for x1=0 to 7
            putChars(x1*3,y1*3,3,3,tiles(peek(adr+x1)))
        next x1
    next y1
end sub
sub monster(posx as ubyte,posy as ubyte,monster as ubyte,direction as ubyte)
    dim adr as uinteger
    if monster=0
        if direction=0 'N
            if alt=0
                adr=@GoshiraU1
            elseif alt=1
                adr=@GoshiraU1
            end if
        elseif direction=1 'W
            if alt=0
                adr=@GoshiraL1
            elseif alt=1
                adr=@GoshiraL2
            end if
        elseif direction=2 'S
            if alt=0
                adr=@GoshiraD1
            elseif alt=1
                adr=@GoshiraD1
            end if
        elseif direction=3 'E
            if alt=0
                adr=@GoshiraR1
            elseif alt=1
                adr=@GoshiraR1
            end if
        end if
    
    end if
    
    putChars(posx*3,posy*3,3,3,adr)
    paint(posx*3,posy*3,3,3,32)
    alt=1-alt
end sub
sub deletemonster(monsterx as ubyte,monstery as ubyte)
    putChars(monsterx*3,monstery*3,3,3,@void)
    paint(monsterx*3,monstery*3,3,3,7)
    if gettile(monsterx,monstery)=5
        settile(monsterx,monstery,4)
    end if
    putChars(monsterx*3,monstery*3,3,3,@Schutt)
end sub
sub status()
    ink 7
    print at 1,24;directionstring$(winddir)
    print at 4,24;directionstring$(headingdir)
end sub
function gettile(x as ubyte,y as ubyte) as ubyte
    return peek(@buffer+y*32+x)
end Function
sub settile(x as ubyte,y as ubyte,tile as ubyte)
    poke @buffer+y*32+x,tile
    putChars(monsterx*3,monsterx*3,3,3,@void)
end sub

start:
border 0: ink 7:paper 0:bright 0: flash 0: inverse 0:over 0:cls
megaLZDepack(@title,@buffer)
putChars(1,1,30,14,@buffer)

Dim font (767) As uByte => { _
      0,  0,  0,  0,  0,  0,  0,  0, _
     24, 24, 24, 24, 24,  0, 24,  0, _
    102,102,102,  0,  0,  0,  0,  0, _
      0,108,254,108,108,254,108,  0, _
     24, 62, 96, 60,  6,124, 24,  0, _
      0,102,108, 24, 48,102, 70,  0, _
     56,108, 56,112,222,204,118,  0, _
     24, 24, 24,  0,  0,  0,  0,  0, _
     14, 28, 24, 24, 24, 28, 14,  0, _
    112, 56, 24, 24, 24, 56,112,  0, _
      0,102, 60,255, 60,102,  0,  0, _
      0, 24, 24,126, 24, 24,  0,  0, _
      0,  0,  0,  0,  0, 48, 48, 96, _
      0,  0,  0,126,  0,  0,  0,  0, _
      0,  0,  0,  0,  0, 24, 24,  0, _
      2,  6, 12, 24, 48, 96, 64,  0, _
     60,102,110,118,102,102, 60,  0, _
     24, 56, 24, 24, 24, 24,126,  0, _
     60,102,  6, 12, 24, 48,126,  0, _
    126, 12, 24, 12,  6,102, 60,  0, _
     12, 28, 60,108,126, 12, 12,  0, _
    126, 96,124,  6,  6,102, 60,  0, _
     60, 96, 96,124,102,102, 60,  0, _
    126,  6, 12, 24, 48, 48, 48,  0, _
     60,102,102, 60,102,102, 60,  0, _
     60,102,102, 62,  6, 12, 56,  0, _
      0, 24, 24,  0, 24, 24,  0,  0, _
      0, 24, 24,  0, 24, 24, 48,  0, _
      6, 12, 24, 48, 24, 12,  6,  0, _
      0,  0,126,  0,  0,126,  0,  0, _
     96, 48, 24, 12, 24, 48, 96,  0, _
     60,102,  6, 12, 24,  0, 24,  0, _
     60,102,110,106,110, 96, 62,  0, _
     24, 60,102,102,126,102,102,  0, _
    124,102,102,124,102,102,124,  0, _
     60,102, 96, 96, 96,102, 60,  0, _
    120,108,102,102,102,108,120,  0, _
    126, 96, 96,124, 96, 96,126,  0, _
    126, 96, 96,124, 96, 96, 96,  0, _
     62, 96, 96,110,102,102, 62,  0, _
    102,102,102,126,102,102,102,  0, _
     60, 24, 24, 24, 24, 24, 60,  0, _
      6,  6,  6,  6,  6,102, 60,  0, _
    102,108,120,112,120,108,102,  0, _
     96, 96, 96, 96, 96, 96,126,  0, _
    198,238,254,214,198,198,198,  0, _
    102,118,126,126,110,102,102,  0, _
     60,102,102,102,102,102, 60,  0, _
    124,102,102,124, 96, 96, 96,  0, _
     60,102,102,102,118,108, 54,  0, _
    124,102,102,124,108,102,102,  0, _
     60,102, 96, 60,  6,102, 60,  0, _
    126, 24, 24, 24, 24, 24, 24,  0, _
    102,102,102,102,102,102, 62,  0, _
    102,102,102,102,102, 60, 24,  0, _
    198,198,198,214,254,238,198,  0, _
    102,102, 60, 24, 60,102,102,  0, _
    102,102,102, 60, 24, 24, 24,  0, _
    126,  6, 12, 24, 48, 96,126,  0, _
     30, 24, 24, 24, 24, 24, 30,  0, _
     64, 96, 48, 24, 12,  6,  2,  0, _
    120, 24, 24, 24, 24, 24,120,  0, _
     16, 56,108,198,  0,  0,  0,  0, _
      0,  0,  0,  0,  0,  0,254,  0, _
      0,192, 96, 48,  0,  0,  0,  0, _
      0,  0, 60,  6, 62,102, 62,  0, _
     96, 96,124,102,102,102,124,  0, _
      0,  0, 60, 96, 96, 96, 60,  0, _
      6,  6, 62,102,102,102, 62,  0, _
      0,  0, 60,102,126, 96, 60,  0, _
     28, 48,124, 48, 48, 48, 48,  0, _
      0,  0, 62,102,102, 62,  6,124, _
     96, 96,124,102,102,102,102,  0, _
     24,  0, 56, 24, 24, 24, 60,  0, _
     24,  0, 24, 24, 24, 24, 24,112, _
     96, 96,102,108,120,108,102,  0, _
     56, 24, 24, 24, 24, 24, 60,  0, _
      0,  0,236,254,214,198,198,  0, _
      0,  0,124,102,102,102,102,  0, _
      0,  0, 60,102,102,102, 60,  0, _
      0,  0,124,102,102,102,124, 96, _
      0,  0, 62,102,102,102, 62,  6, _
      0,  0,124,102, 96, 96, 96,  0, _
      0,  0, 62, 96, 60,  6,124,  0, _
      0, 24,126, 24, 24, 24, 14,  0, _
      0,  0,102,102,102,102, 62,  0, _
      0,  0,102,102,102, 60, 24,  0, _
      0,  0,198,198,214,124,108,  0, _
      0,  0,102, 60, 24, 60,102,  0, _
      0,  0,102,102,102, 62,  6,124, _
      0,  0,126, 12, 24, 48,126,  0, _
     14, 24, 24, 48, 24, 24, 14,  0, _
     24, 24, 24, 24, 24, 24, 24, 24, _
    112, 24, 24, 12, 24, 24,112,  0, _
      0, 96,242,158, 12,  0,  0,  0, _
      0, 24, 24, 52, 52, 98,126,  0 _
}
Poke uInteger 23606, (@font (0)) - 256
dim mapx,mapy as ubyte

print at 16,2;"Monster";at 22,0;"\{i1}by LCD using ZX BASIC Compiler."

waitkey()

cls
paint(24,0,8,24,15)
paper 1:ink 5
print at 0,24;"WIND"
print at 3,24;"HEADING"
print at 6,24;"TIME"
print at 9,24;"HEADTILT"
mapx=0:mapy=0
monsterx=1
monstery=1
CopyMem(@mapSF,@buffer,1024)
drawmap(0,0)

gameloop8:
WaitNoKey()
status()
monster(monsterx,monstery,0,headingdir)
gameloop9:
key$=inkey$
if key$="l"
    headingdir=headingdir+1:if headingdir=4:headingdir=0:end If
    goto gameloop8
elseif key$="r"
    headingdir=headingdir-1:if headingdir=-1:headingdir=3:end If
    goto gameloop8
elseif key$="m"
    deletemonster(monsterx,monstery)
    
    if headingdir=0 and monstery>0 and (gettile(monsterx,monstery-1)=0 or gettile(monsterx,monstery-1)=1)
        monstery=monstery-1
    elseif headingdir=2 and monstery<31
        monstery=monstery+1
    elseif headingdir=1 and monsterx<7
        monsterx=monsterx+1
    elseif headingdir=3 and monsterx>0
        monsterx=monsterx-1
    elseif headdir=1 and monsterx>6
        monsterx=0
        mapx=mapx+8
        drawmap(mapx,mapy)
    
    end if
    goto gameloop8
end if
goto gameloop9
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
Thanks, will test it.
Also, the new syntax allows directly initializing arrays with complex constant expressions like @labels or @label + 2 * @label3. So, try you could replace:

Code:
DIM tiles(16) as Uinteger: REM <== Positions 10..16 are not used??

tiles(0)=@void
tiles(1)=@Sea
tiles(2)=@Bridge
tiles(3)=@Park
tiles(4)=@Schutt
tiles(5)=@skyscraper

tiles(6)=@car
tiles(7)=@PoliceCar
tiles(8)=@People
tiles(9)=@house
to
Code:
DIM tiles(9) as UInteger => { @void, @Sea, @Bridge, _
    @Park, @Schutt, @skyscraper, _
    @car, @PoliceCar, @People, @house }

:!: Notice that in the 2nd way, it's an initialization, so the number of elements of the array (0 .. 9 => 10) must match the number of elements between brackets.
(cannot test it at this moment, but should work)
Reply
boriel Wrote:Thanks, will test it.
Also, the new syntax allows directly initializing arrays with complex constant expressions like @labels or @label + 2 * @label3. So, try you could replace:

Code:
DIM tiles(16) as Uinteger: REM <== Positions 10..16 are not used??

tiles(0)=@void
tiles(1)=@Sea
tiles(2)=@Bridge
tiles(3)=@Park
tiles(4)=@Schutt
tiles(5)=@skyscraper

tiles(6)=@car
tiles(7)=@PoliceCar
tiles(8)=@People
tiles(9)=@house
to
Code:
DIM tiles(9) as UInteger => { @void, @Sea, @Bridge, _
    @Park, @Schutt, @skyscraper, _
    @car, @PoliceCar, @People, @house }

:!: Notice that in the 2nd way, it's an initialization, so the number of elements of the array (0 .. 9 => 10) must match the number of elements between brackets.
(cannot test it at this moment, but should work)

Looks like very useful feature. I will test it later with some other Programs.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
LCD Wrote:Oh, Found a bug, I think:
Code:
Traceback (most recent call last):
  File "D:\Restliche Programme\zxbasic\zxb.py", line 339, in <module>
    sys.exit(main())  # Exit
  File "D:\Restliche Programme\zxbasic\zxb.py", line 244, in main
    debug=(OPTIONS.Debug.value > 2))
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 328, in parse
    return self.parseopt(input, lexer, debug, tracking, tokenfunc)
  File "D:\Restliche Programme\zxbasic\ply\yacc.py", line 820, in parseopt
    p.callable(pslice)
  File "D:\Restliche Programme\zxbasic\zxbparser.py", line 2461, in p_addr_of_id
    entry.accessed = True
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 39, in accessed
    for entry in self.scope_owner:
  File "D:\Restliche Programme\zxbasic\symbols\label.py", line 44, in scope_owner
    return list(self._scope_owner)
AttributeError: 'SymbolLABEL' object has no attribute '_scope_owner'
That was without optimizer, in this code:
Code:
dim tiles(16) as uinteger
tiles(0)=@void
...
Next time better post the bugs in the Bug Reports folder in the forum.
I think this one is fixed (the -O3 one still pending).
Can you download one of these beta-versions and test if it works, please?  Rolleyes

http://boriel.com/files/zxb/zxbasic-1.8....-win32.zip
http://boriel.com/files/zxb/zxbasic-1.8.1-beta3.tar.gz
http://boriel.com/files/zxb/zxbasic-1.8.1-beta3.zip
Reply
LCD Wrote:
boriel Wrote:Ok. This seems to be with -O3. Using -O2 or lower should give no problems.
That's true.
Today I made a big progress with BorIDE. Custom loader (Counter Load) works also too. Hope to release it soon.

Ok, I think I've fixed it.
Can you download and check from here, please??  Rolleyes

http://boriel.com/files/zxb/zxbasic-1.8....-win32.zip
http://boriel.com/files/zxb/zxbasic-1.8.1-beta3.tar.gz
http://boriel.com/files/zxb/zxbasic-1.8.1-beta3.zip

These include the fix from the other patch (crash with -O2 with the other source).
Try this and tell me.
Reply
Yes, you are right. I should have post it in the bug section.
Next time I will do so.
Will check the new compiler ASAP (New project from my job started, and one improvement screwed my linking code). Will try to fix it today after work.
But I think, the improvement was worth it.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)