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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 262
» Latest member: AnthonyGaxia
» Forum threads: 1,075
» Forum posts: 6,440

Full Statistics

Online Users
There are currently 173 online users.
» 0 Member(s) | 172 Guest(s)
Bing

Latest Threads
Красивые букетики
Forum: News
Last Post: AnthonyGaxia
10 hours ago
» Replies: 0
» Views: 13
Printing with FZX
Forum: Help & Support
Last Post: boriel
07-17-2025, 09:08 PM
» Replies: 1
» Views: 362
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 2,534
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 2,713
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 2,266
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 5,268
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 3,700
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 3,437
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 1,955
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 4,740

 
  What don't we know about?
Posted by: britlion - 05-22-2010, 10:58 PM - Forum: Documentation - Replies (3)

Boriel,

I am willing to help with the wiki version of documentation. Actually, I think I've probably put edits into half of it *chuckle*; including starting a "library" section and listing things like Fsin, Fsqrt and iSqrt. I think that it's possible to work out the Sinclair Basic compatible statements, but anything not compatible needs to be documented more fully. So let's start with that.

1> Are there any words that are NOT already in the reserved word list - <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Identifier#Reserved_Identifiers">http://www.boriel.com/wiki/en/index.php ... dentifiers</a><!-- m --> that we should know about?

2> Are there any extensions to the language, such as with PEEK and OVER that we don't have documented there?

Print this item

  DO WHILE and DO UNTIL
Posted by: programandala.net - 05-22-2010, 02:31 PM - Forum: Wishlist - Replies (5)

Here you are my first two cents for the wishing well:

Now the DO-LOOP syntax is:

Quote:Do
[ statement block ]
Loop [ { Until | While } condition ]

I miss the following variant, allowed in FreeBASIC, Beta Basic and others:

Quote:Do [ { Until | While } condition ]
[ statement block ]
Loop

I think it's nice and clear to use just one loop structure and simply move the conditions. In fact the (less elegant, in my opinion) WHILE-WHILE END structure would be redundant (though it exists in FreeBASIC too).

Print this item

  Small snippet to make the AY scream a bit
Posted by: na_th_an - 05-19-2010, 02:27 PM - Forum: How-To & Tutorials - Replies (19)

I ported some old code I developed with the aid of a couple of snippets published in Microhobby and some documentation for the AY chip to ZX Basic. The original was plain interpreted Sinclair BASIC. It may be useful to create simple sound effects, but nothing very fancy. Porting WYZ's replayer would be a better idea, but I have no time at the moment.

Try this:

Code:
Dim sonidos (4, 13) As Byte => {_
    {100,50,0,0,0,0,4,216,31,0,0,10,10,0}, _
    {250,250,0,0,0,0,15,248,31,0,0,10,10,0}, _
    {10,10,0,0,0,0,29,216,31,0,0,4,4,0}, _
    {10,100,0,0,0,0,15,248,31,0,0,50,50,0}, _
    {15,1,0,0,0,0,15,248,31,0,0,50,50,0} _
}
Dim n As Byte

Cls
For n = 0 To 4                          ' We'll play 4 sounds
    Print "SFX #"; n                    ' Print which one
    ayPlaySound (n)                     ' Play sound # i
    Pause 100                           ' Wait for 2 secs.
Next n

Sub ayPlaySound (sonido As Byte)
    ' This SUB plays the sound passed as parameter
    ' Sounds are taken from table "sonidos", which
    ' must be defined globally.

    Dim i As Byte
  
    For i = 0 To 13
        Out 65533, i                    ' Select which AY register
        Out 49149, sonidos (sonido, i)  ' Write a value in it
    Next i
End Sub

The values in the array are pretty straightforward. The first 14 AY registers are written by the routine, just look at this table and you may create your own wacky sounds.

Code:
AY REGISTERS

00              Channel A fine pitch            8-bit (0-255)
01              Channel A course pitch          4-bit (0-15)
02              Channel B fine pitch            8-bit (0-255)
03              Channel B course pitch          4-bit (0-15)
04              Channel C fine pitch            8-bit (0-255)
05              Channel C course pitch          4-bit (0-15)
06              Noise pitch                     5-bit (0-31)
07              Mixer                           8-bit (see below)
08              Channel A volume                4-bit (0-15, see below)
09              Channel B volume                4-bit (0-15, see below)
10              Channel C volume                4-bit (0-15, see below)
11              Envelope fine duration          8-bit (0-255)
12              Envelope course duration        8-bit (0-255)
13              Envelope shape                  4-bit (0-15)
14              I/O port A                      8-bit (0-255)
15              I/O port B                      8-bit (0-255)

Bit:
7       6        5        4        3        2        1        0
_         _
I/O     I/O     Noise    Noise    Noise     Tone     Tone     Tone
B        A        C        B        A        C        B        A

Print this item

  ZXBasic 1.2.6-r1561
Posted by: boriel - 04-29-2010, 05:46 PM - Forum: Bug Reports - Replies (2)

This is a new beta version (released a minute ago :!Smile. Basically it adds 3 new command line parameters:

  • --strict-boolean will enforce boolean results to be always 0 or 1 (with a slight impact on performance). Using --sinclair also enables this feature.
  • --debug-array will raise an error if an array access is made out of boundaries (3 Subscript Wrong)
  • --debug-memory will raise an error when out of memory. This might happen when working with strings

Using --debug-xxx will affect a bit the program speed (due to extra checking). So this should only be used during development stage. :wink:

Download at <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb">http://www.boriel.com/files/zxb</a><!-- m --> as always...

Print this item

  Missing label issue *found*
Posted by: britlion - 04-21-2010, 08:24 AM - Forum: Help & Support - Replies (2)

I have a program (fourspriter. Yet again!) that has a compilation error "no such label". Except I can see it. Right there! :-)

Am I going crazy?

I copied and pasted the following code into a separate project:

Code:
SUB FASTCALL fspUpdate()
asm
fspUpdateAsm:
         ld     hl, fspDataStartAsm+1     ; Points to sprite 1
         ld     de, fspDataStartAsm+3            
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43     ; Points to sprite 2
         ld     de, fspDataStartAsm+3+43                  
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43     ; Points to sprite 3
         ld     de, fspDataStartAsm+3+43+43                
         ldi
         ldi

         ld     hl, fspDataStartAsm+1+43+43+43     ; Points to sprite 4
         ld     de, fspDataStartAsm+3+43+43+43                    
         ldi
         ldi
         ret
END asm
END SUB

SUB fspCollisionCheck()
END SUB


SUB FASTCALL fspRedraw()
   fspCollisionCheck()
asm
   halt
   call fspEraseAsm
   call fspBufferAndDrawAsm
   call fspUpdateAsm
end asm                                          
END SUB

fspRedraw()

And it compiled perfectly. Which is bad, because this is FULL of references that don't exist. However, when I try the main code block, it reports:

FourSpriter3.bas:906: Error: Undefined label 'fspUpdateAsm'

Now, quite apart from the fact that line 906 reads " ;LD BC,2120 "- which means I have to hunt down the line it really means, that label is only used in two places. Both of those places are shown in the code above. One call and one arrival point.

I have NO idea why it's doing this. It's weird that it doesn't like the label in the main program, and yet is fine with all those other undefined labels in the part above. Any idea what's going on here?

Print this item

  how to use a standard character set
Posted by: programandala.net - 04-20-2010, 12:52 PM - Forum: How-To & Tutorials - Replies (3)

Sometimes, in order to use the Spanish characters (áéíóúüñÁÉÍÓÚÜÑ¿¡) in my Spectrum programs, I put them in the place of less used Spectrum chars (#, ', @...).

In the source code of my current project there's a lot of Spanish texts to be printed by the Spectrum. It would be uncomfortable to use those fake chars all over the source. Then I had a quite brilliant Wink idea: Let's use the same standard character set both in the source code and in the Spectrum!

First, I wrote a trivial asm sub to change the character set address. Then I added the character graphics, with the Spanish chars in the right position (in the ISO-8859-1 standard). The only needed trick is to fill the gaps of the unused chars. Happily, I already had all the character definitions is assembler DEFBs, in another project of mine.

This is the first part of the sub:

Code:
sub fastcall changeCharacterSet()

    asm

systemCHARS    equ 23606

    jp actuallyChangeCharacterSet

characterSet equ $-256

;(space)
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
    defb %00000000
;!
    defb %00000000
    defb %00010000
    defb %00010000
    defb %00010000
    defb %00010000
    defb %00000000
    defb %00010000
    defb %00000000

And so on... This is the end:

Code:
    defs (243-241-1)*8 ; unused chars
;ó = 243
    defb %00001000
    defb %00010000
    defb %00111000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

    defs (250-243-1)*8 ; unused chars
;ú = 250
    defb %00001000
    defb %00010000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

    defs (252-250-1)*8 ; unused chars
;ü = 252
    defb %01000100
    defb %00000000
    defb %01000100
    defb %01000100
    defb %01000100
    defb %01000100
    defb %00111000
    defb %00000000

actuallyChangeCharacterSet:

    ld hl,characterSet
    ld (systemCHARS),hl

    end asm
end sub

Easy, isn't it?

The next task is to hack the print.asm library in order to print all characters from 32 to 255. I show the removed or added lines (they are clearly marked):

First:

Code:
; 1 LINE REMOVED:
;        LOCAL __PRINT_UDG

And then the rest:

Code:
; 8 LINES REMOVED:
;        cp 80h    ; Is it an UDG or a ?
;        jp c, __SRCADDR

;        cp 90h
;        jp nc, __PRINT_UDG

        ; Print a 8 bit pattern (80h to 8Fh)

;        ld b, a
;        call PO_GR_1 ; This ROM routine will generate the bit pattern at MEM0
;        ld hl, MEM0
;        jp __PRGRAPH

PO_GR_1 EQU 0B38h

; 4 LINES REMOVED:
;__PRINT_UDG: ;REMOVED
;        sub 90h ; Sub ASC code
;        ld bc, (UDG)
;        jp __PRGRAPH0

__SOURCEADDR EQU (__SRCADDR + 1)    ; Address of the pointer to chars source
__SRCADDR:
        ld bc, (CHARS)

__PRGRAPH0:
; 1 LINE REMOVED:
;        add a, a    ; A = a * 2 (since a < 80h) ; Thanks to Metalbrain at http://foro.speccy.org
        ld l, a
        ld h, 0        ; HL = a * 2 (accumulator)
        add hl, hl
; 1 LINE ADDED:
        add hl, hl
        add hl, hl ; HL = a * 8
        add hl, bc ; HL = CHARS address

__PRGRAPH:

That's all. Now all characters from 32 to 255 are in the same set: no block graphics, no UDGs, no Basic tokens. Any desired graphic can be defined in any character code. Any standard 8-bit character set can be used. Now I can write the Spanish texts in the source and they show perfectly on the Spectrum's screen.

I'd like my hacked version to be an independent library, to be #included, and used with a new command (print224, printplus or whatever). But rigth now that task is beyond my current skill with ZX Basic. Any help?

Another issue is to use the gaps of the unused chars for variables, but I'm still not sure how to use asm labels in ZX Basic. I have to explore it. Any help?

Now I will tinker with the second part of the system: I have to modify my own input routine, to let it accept some key combinations (e.g. Symbol Shift (+Shift)+letter) to get the Spanish characters...

Print this item

  --asm and --tap together
Posted by: programandala.net - 04-20-2010, 10:05 AM - Forum: Wishlist - Replies (4)

Some times I need to check the assembler, and I have to compile the sources twice in order to get also the .TAP file, because anyway I need to execute the program too.

Maybe in the future both the assembler file and the object file could be created with one single command?

Print this item

  values returned by comparations
Posted by: programandala.net - 04-19-2010, 07:52 PM - Forum: Bug Reports - Replies (4)

I realized that some comparations with string lenghts return different values than in Sinclar Basic:

Code:
dim text as string
let text="A"
print len(text)=1 ' prints 0!
print len(text)=len(text) ' prints 255!
print 2=2 ' prints 1 as expected

Why?

Print this item

  string slicing using len()
Posted by: programandala.net - 04-19-2010, 04:09 PM - Forum: Help & Support - Replies (3)

I didn't understand why a piece of my program didn't work as expected. I suspected something was wrong with the for-next loop. I tried some tests, simplified versions of the problem, and finally find out the following:

Code:
dim text as string
dim i as ubyte

let text="hello world!"

cls
print "Fine:"
for i = 0 to len(text)-1
    print i,text(to i)
next i

pause 0
cls
print "All texts are complete!:"
for i = 0 to len(text)-1
    print i,;
    let text = text(to len(text)-1)
    print text
next i

stop
It was a surprise. The second loop prints the same original text every time.

I tried the equivalent code in Sinclair Basic, and of course it worked as expected:
Code:
10 LET A$="hello world!"
20 FOR I=0 TO LEN(A$)-1
30 PRINT I,;
40 LET A$=A$(TO LEN(A$)-1)
50 PRINT A$
60 NEXT I
70 STOP

Then I tried it without the loop:

Code:
dim text as string
let text="hello world!"
cls
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
let text = text(to len(text)-1)
print text
stop
And the problem remained.
Then I hardcoded some slicing values:
Code:
dim text as string
let text="hello world!"
print text
let text = text(to 10)
print text
let text = text(to 9)
print text
let text = text(to 8)
print text
let text = text(to 7)
print text
let text = text(to 6)
print text
let text = text(to 5)
print text
stop
And it worked fine.

Is there something I'm missing in my code or is it a compiler issue?

Print this item

  How to change the compiling ORG address?
Posted by: programandala.net - 04-19-2010, 12:52 PM - Forum: Help & Support - Replies (1)

I wonder how to change the default address 32768. I've searched for "org" in the forum archive, but all references are about the assembler ORG. There's no mention in the wiki either.
I blindly tried this:

Code:
org 30000
And this:
Code:
#org 30000
But they are not accepted. Then I tried this:
Code:
asm
org 24000
end asm
print "hello"
stop
And got the following assembler:
Code:
    org 32768
__START_PROGRAM:
    di
    push ix
    push iy
    exx
    push hl
    exx
    ld hl, 0
    add hl, sp
    ld (__CALL_BACK__), hl
    ei
    call __PRINT_INIT
#line 3
        org 24000
#line 4
    ld hl, __LABEL0
    call PRINT_STR
    call PRINT_EOL
    ld a, 8
    call __STOP
    ld hl, 0
    ld b, h
    ld c, l
__END_PROGRAM:
    di
    ld hl, (__CALL_BACK__)
    ld sp, hl
    exx
    pop hl
    exx
    pop iy
    pop ix
    ei
    ret
I searched for "or" and "pragma" through the sources, but I found no clue.

Print this item