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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 384
» Latest member: Steventrato
» Forum threads: 1,028
» Forum posts: 6,212

Full Statistics

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

Latest Threads
Includes in ASM
Forum: How-To & Tutorials
Last Post: bracckets
04-04-2024, 12:17 AM
» Replies: 2
» Views: 498
Intermittent errors
Forum: Help & Support
Last Post: zarsoft
03-12-2024, 12:39 PM
» Replies: 0
» Views: 299
Store array information i...
Forum: Help & Support
Last Post: rbiondi
03-10-2024, 09:42 PM
» Replies: 0
» Views: 383
ScrollLeft function scrol...
Forum: Bug Reports
Last Post: rbiondi
03-07-2024, 03:57 PM
» Replies: 2
» Views: 767
string.bas errors when co...
Forum: Bug Reports
Last Post: rbiondi
03-01-2024, 10:10 AM
» Replies: 2
» Views: 681
Using Beepola with ZX BAS...
Forum: How-To & Tutorials
Last Post: edtoo
02-29-2024, 09:47 AM
» Replies: 15
» Views: 32,466
Johnny Bravo
Forum: Gallery
Last Post: zarsoft
02-11-2024, 11:20 PM
» Replies: 0
» Views: 459
Compiling +D G+DOS progra...
Forum: ZX Basic Compiler
Last Post: boriel
01-22-2024, 08:32 AM
» Replies: 4
» Views: 8,571
VAL = ? (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:44 PM
» Replies: 8
» Views: 3,093
Wrong math (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:38 PM
» Replies: 4
» Views: 1,669

 
  Suggestion about the forum
Posted by: programandala.net - 05-23-2010, 09:48 AM - Forum: ZX Basic Compiler - No Replies

Now we have sub-forums for Help&Support and Documentation. That makes things tidier, especially with a growing forum.

I think this original top-level forum I'm posting into creates a kind of ambiguity, it's not clear what its purpose is any more.

I suggest to use it only for announcing new releases, or general announcements of the developer. Maybe it could be a read-only sub-forum for the users? The rest of the current messages would be moved into the proprer sub-forums.

More: This top-level forum itself could be moved into a new "Release announcements" or "Developer announcements" sub-forum, so the sub-forums list would be plain clear: no doubt where to post.

Just for your consideration.

Print this item

  A skeleton for the docs; contents hierarchy
Posted by: programandala.net - 05-23-2010, 09:23 AM - Forum: Documentation - Replies (1)

I suggest to use the FreeBASIC docs as a guide, especially the FreeBASIC Table of Contents. What do you think?

By the way, I see a problem about FreeBASIC wiki: it lacks page hierarchy, it doesn't show a breadcrumb on the top, what is very important to see where we are in the page tree. Many wikis lack that feature. Some of them use the raw page name (e.g. "main.reference.functions" would be a deeper level than "main.reference"); others use page metadata to configure the hierarchy (what is more flexible because page names can change without changing the structure).

Another possible model is the PHP documentation (see an example of PHP doc page): description, parameters, return values, examples, see also, user contributions...

Print this item

  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