Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 267
» Latest member: LorenzoTethy
» Forum threads: 1,075
» Forum posts: 6,435

Full Statistics

Online Users
There are currently 209 online users.
» 0 Member(s) | 207 Guest(s)
Bing, Google

Latest Threads
Strange Happenings
Forum: Bug Reports
Last Post: zedex82
6 hours ago
» Replies: 0
» Views: 4
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 367
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 310
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,620
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 570
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 909
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 353
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,077
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,902
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 425

 
  Spectrum resets
Posted by: slenkar - 08-15-2012, 01:27 AM - Forum: Help & Support - Replies (5)

I was programming the same game and the speccy resets, is there a way of telling which line it crashes on?

(except commenting out loads of lines)

Print this item

  Empty string crash (*solved*)
Posted by: britlion - 08-03-2012, 11:21 PM - Forum: Bug Reports - Replies (3)

Compiler crashes if a sub is sent an empty string:

Code:
SUB stringtest (thing as string)
asm
DI
HALT
END ASM
END SUB

stringtest("")

Print this item

  Peek (uInteger,@label) problem (*solved*)
Posted by: LCD - 08-02-2012, 08:19 PM - Forum: Bug Reports - Replies (2)

Hallo Boriel,
I just found following Problem in s888 and s894

Code:
paper 7:ink 0:border 7:cls
print peek(uinteger,@test)
print peek(@test)+256*peek(@test+1)
End
test:
asm
    defw 35600
end asm
It should print in both cases the value 35600, but the first number looks like the address of the test label.

Print this item

  aplib decompressor for ZX Basic.
Posted by: na_th_an - 08-02-2012, 11:18 AM - Forum: How-To & Tutorials - Replies (28)

1. Download the compressor -> <!-- m --><a class="postlink" href="http://www.mojontwins.com/warehouse/apack.zip">http://www.mojontwins.com/warehouse/apack.zip</a><!-- m -->
2. Pack your binaries using it:

Code:
> apack.exe input.bin output.bin
3. Include your packed binaries in your program
Code:
packed:
Asm
   Binary "output.bin"
End Asm
4. Include the aplib decompressor (by dwedit/metalbrain/utopian) in your program
Code:
#include once "aplib.bas"
5. Call the depacker to decompress your binary to somewhere else (source, destination):
Code:
aplibUnpack (@packed, 16384)

Here's aplib.bas:
Code:
'' aplib.bas

Sub aplibDummyContainer
    asm
    
    ; aPPack decompressor
    ; original source by dwedit
    ; very slightly adapted by utopian
    ; optimized by Metalbrain
    ; Adapted for ZX Basic by na_th_an
    
    ;hl = source
    ;de = dest

    depack:    
            ld    ixl,128
    apbranch1:    
            ldi
    aploop0:    
            ld    ixh,1        ;LWM = 0
    aploop:        
            call     ap_getbit
            jr     nc,apbranch1
            call     ap_getbit
            jr     nc,apbranch2
            ld     b,0
            call     ap_getbit
            jr     nc,apbranch3
            ld    c,16        ;get an offset
    apget4bits:    
            call     ap_getbit
            rl     c
            jr    nc,apget4bits
            jr     nz,apbranch4
            ld     a,b
    apwritebyte:
            ld     (de),a        ;write a 0
            inc     de
            jr    aploop0
    apbranch4:
            and    a
            ex     de,hl         ;write a previous byte (1-15 away from dest)
            sbc     hl,bc
            ld     a,(hl)
            add    hl,bc
            ex     de,hl
            jr    apwritebyte
    apbranch3:
            ld     c,(hl)        ;use 7 bit offset, length = 2 or 3
            inc     hl
            rr     c
            ret     z        ;if a zero is encountered here, it is EOF
            ld    a,2
            adc    a,b
            push     hl
            ld    iyh,b
            ld    iyl,c
            ld     h,d
            ld     l,e
            sbc     hl,bc
            ld     c,a
            jr    ap_finishup2
    apbranch2:
            call     ap_getgamma    ;use a gamma code * 256 for offset, another gamma code for length
            dec     c
            ld    a,c
            sub    ixh
            jr     z,ap_r0_gamma        ;if gamma code is 2, use old r0 offset,
            dec     a
            ;do I even need this code?
            ;bc=bc*256+(hl), lazy 16bit way
            ld     b,a
            ld     c,(hl)
            inc     hl
            ld    iyh,b
            ld    iyl,c
    
            push     bc
            
            call     ap_getgamma
    
            ex     (sp),hl        ;bc = len, hl=offs
            push     de
            ex     de,hl
    
            ld    a,4
            cp    d
            jr     nc,apskip2
            inc     bc
            or    a
    apskip2:
            ld     hl,127
            sbc     hl,de
            jr     c,apskip3
            inc     bc
            inc     bc
    apskip3:
            pop     hl        ;bc = len, de = offs, hl=junk
            push     hl
            or     a
    ap_finishup:
            sbc     hl,de
            pop     de        ;hl=dest-offs, bc=len, de = dest
    ap_finishup2:
            ldir
            pop     hl
            ld    ixh,b
            jr     aploop
    
    ap_r0_gamma:
            call     ap_getgamma        ;and a new gamma code for length
            push     hl
            push     de
            ex    de,hl
    
            ld    d,iyh
            ld    e,iyl
            jr     ap_finishup
    
    
    ap_getbit:
            ld    a,ixl
            add    a,a
            ld    ixl,a
            ret    nz
            ld    a,(hl)
            inc    hl
            rla
            ld    ixl,a
            ret
    
    ap_getgamma:
            ld     bc,1
    ap_getgammaloop:
            call     ap_getbit
            rl     c
            rl     b
            call     ap_getbit
            jr     c,ap_getgammaloop
            ret
    End Asm
apDataPool:
    Asm
    ap__source:
            defw 0
    ap__destination:
            defw 0
    End Asm
End Sub

Sub aplibUnpack (source as uInteger, destination as uInteger)
    Poke uInteger @apDataPool, source
    Poke uInteger 2 + @apDataPool, destination
    Asm
        ld hl, (ap__source)
        ld de, (ap__destination)
        di
        push ix
        push iy
        call depack
        pop iy
        pop ix
        ei
    End Asm
End Sub

Happy coding!

Print this item

  compilation error (*solved*)
Posted by: slenkar - 08-02-2012, 03:59 AM - Forum: Bug Reports - Replies (6)

I have a compilation eror where it thinks a byte is a label



Attached Files
.bas   linefile.bas (Size: 1.69 KB / Downloads: 437)
.bas   wars.bas (Size: 7.1 KB / Downloads: 322)
.bas   pressedfire.bas (Size: 2.09 KB / Downloads: 267)
Print this item

  zxbasic compiler for Sega Master System?
Posted by: nitrofurano - 08-01-2012, 11:26 AM - Forum: Wishlist - Replies (20)

i knew now that someone adapted zxbasic compiler to create Sega Master System roms? did someone try it?
<!-- m --><a class="postlink" href="http://www.smspower.org/forums/viewtopic.php?t=12902">http://www.smspower.org/forums/viewtopic.php?t=12902</a><!-- m -->

if it is working fine, or close to it, maybe it could somehow be available officially here from Boriel's website?

Print this item

  BIFROST* Advanced Programming
Posted by: einar - 07-27-2012, 08:28 PM - Forum: ZX Basic Compiler - Replies (6)

I posted here the first example that demonstrates how to use the "internal routines" in BIFROST*:

<!-- m --><a class="postlink" href="http://www.worldofspectrum.org/forums/showthread.php?t=40246">http://www.worldofspectrum.org/forums/s ... hp?t=40246</a><!-- m -->

Unfortunately this example was implemented in z88dk. However the same API is available for ZX BASIC and the solution would be exactly the same, thus I think this link will be also useful for ZX BASIC programmers interested in BIFROST*.

Perhaps someone here could translate this example to ZX BASIC and post it, or implement similar demos?

Print this item

  Sub Fastcall behaviour
Posted by: na_th_an - 07-27-2012, 11:39 AM - Forum: Bug Reports - Replies (6)

I understand that if, for example, you pass an uByte parameter, it's put into the A register... But it seems that the parameter itself is not usable from BASIC. I don't know if this is intended, there's nothing about this in the doc.

Code:
Sub Fastcall test (n as uByte)
    Asm
        ld (40000),a
    End Asm
    Print n
        Print Peek (40000)
End Sub

test (16)

I expected this code to print 16 twice, but it outputs:

Code:
0
16

This is, the value of "n" is 0. In other scenarios, I get other values, not just 0.

Print this item

  What's wrong with this? (*solved*)
Posted by: na_th_an - 07-26-2012, 09:37 AM - Forum: Bug Reports - Replies (11)

Maybe I'm just being thick:

Code:
Sub Fastcall tdPutChar (c as uByte)
    Asm
        rst 16
    End Asm
End Sub

Sub tdPrint (cad As String)
    Dim i As uByte
    For i = 1 To Len (cad)
        tdPutChar (cad (i))
    Next i
End Sub

Compiler output:

Code:
H:\Dev\Speccy\mt64x32lib\zxbasic>c:\zxb\zxb textdongle.bas
Traceback (most recent call last):
  File "zxb.py", line 312, in <module>
  File "zxb.py", line 241, in main
  File "ply\yacc.pyc", line 263, in parse
  File "ply\yacc.pyc", line 710, in parseopt
  File "zxbparser.pyc", line 1744, in p_statement_call
  File "zxbparser.pyc", line 1137, in make_proc_call
  File "zxbparser.pyc", line 744, in check_call_arguments
  File "zxbparser.pyc", line 432, in typecast
  File "zxbparser.pyc", line 1019, in make_typecast
  File "obj\errmsg.pyc", line 22, in syntax_error
TypeError: %d format: a number is required, not NoneType

Print this item

  IM 2
Posted by: na_th_an - 07-25-2012, 01:15 PM - Forum: How-To & Tutorials - Replies (40)

Any special considerations to take in account? I set up my IM 2 ISR routine the same way I do from pure assembly and everything crashes beautifully :lol: (I know the code posted below will crash with hardware attached, this is just a quick test) (and no, no hardware is attached. The floating bus should read $ff).

Code:
Sub activateIsr ()
    Asm
        ld  hl, isr_code
        di
        ld  ($feff), hl
        ld  a, $fe
        ld  i, a
        im  2
        ei
    End Asm
End Sub

Sub allPurposeContainer
    Asm
        isr_code:
        push ix
        push hl
        push af
        ; random shyte
        ld a, r
        out (254), a
        ;
        pop af
        pop hl
        pop ix
        ei
        reti
    End Asm
End Sub

activateIsr ()

While (1): Wend

The "random shyte" section is in fact a bigger routine. Do I have to save all the registers or something like that?

Print this item