| Welcome, Guest |
You have to register before you can post on our site.
|
| Online Users |
There are currently 265 online users. » 0 Member(s) | 264 Guest(s) Bing
|
| Latest Threads |
New video Couse / Nuevo c...
Forum: News
Last Post: Duefectu
2026-04-29, 11:02 PM
» Replies: 0
» Views: 214
|
location of heap manageme...
Forum: Help & Support
Last Post: boriel
2026-03-07, 12:13 AM
» Replies: 1
» Views: 485
|
non-paged supervisor code...
Forum: Help & Support
Last Post: sdo303
2026-02-20, 06:38 PM
» Replies: 8
» Views: 1,301
|
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,389
|
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 2,080
|
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 1,080
|
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 1,179
|
Hall of Fame - Include fo...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-28, 03:48 PM
» Replies: 0
» Views: 630
|
[SOLVED] Array layout bug...
Forum: Bug Reports
Last Post: Zoran
2025-10-25, 05:48 PM
» Replies: 2
» Views: 1,218
|
3DOS Commands?
Forum: Help & Support
Last Post: boriel
2025-10-06, 02:54 PM
» Replies: 3
» Views: 1,381
|
|
|
| Sub Fastcall behaviour |
|
Posted by: na_th_an - 2012-07-27, 12:39 PM - 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:
This is, the value of "n" is 0. In other scenarios, I get other values, not just 0.
|
|
|
| What's wrong with this? (*solved*) |
|
Posted by: na_th_an - 2012-07-26, 10: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
|
|
|
| IM 2 |
|
Posted by: na_th_an - 2012-07-25, 02: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?
|
|
|
| ZXB errores mios de sintaxis o incompatible con SinclairBas? |
|
Posted by: tachuelita - 2012-07-22, 10:17 PM - Forum: ZX Basic Compiler
- Replies (14)
|
 |
Hola a todos, gracias por recibirme en este foro. Sorry por escribir en español, intente' traducir mi texto con el traductor de Google pero confunde mas de lo que explica.
Les cuento que estoy creando un TRACKER para el AY 3-8912 con zx boriel puramente en basic, para poder hacerle Musica y FX a mis juegos, claro que tambien para compartirlo (y aunque alguien me explique como compilar WYZ player, creo que tiene mucho mas mérito para mi, lo tomo como desafio propio).
No es la primera vez que me sucede que alguna rutina no me funciona. Puntualmente en este TOPIC les dejare' las que mas me dieron problema y no entiendo donde esta mi error.
Este "retazo" de rutina funciona con una doble tabla ascii alojada en memoria (50000) brindando 64 columnas a imprimir, para aprovechar mas pantalla. (si, ya se que en LIBRARY del compilador tengo programita que imprime en 64 col, que tampoco se como se usa, pero como dije, a mi me gusta el desafio: "hazlo tu mismo"... tambien se que esta' es bastante precaria a lo basic espectrumero, pero para mejorarla, necesito primero que nada que funcione)
Code: 9550 '------------------------------
'| IMPRIME PATTERN |
'------------------------------
PAUSE 0
BRIGHT 0
FOR f= 0 TO 15
PAPER 7
IF f=0 OR f=4 OR f=8 OR f=12 OR f=16 THEN
PAPER 3
END IF
LET fil = 8 + f
LET col = 1
LET numero = f
LET decimales = 2
GOSUB 9605
NEXT f
STOP
9605 '------------------------------------------------
'\ /
' | INPRESION DE NUMEROS EN 64 COLUMNAS |
'/ \
'------------------------------------------------
'enviar a esta sub rutina:
' fil = fila
' col = columna
' numero
' decimales = 1-unidades
' 2-decenas
' 3-centenas
' 4-mil
' 5-decenas de mil
9606 LET X$=STR$ (numero)
9607 IF decimales > LEN X$ THEN
LET X$="0"+X$
GOTO 9607
END IF
FOR z=0 TO LEN X$ STEP 2
POKE 23607,194
POKE 23606,80
PRINT AT fil,col+(z/2); X$(z)
IF z+1 <= LEN X$ THEN
POKE 23607,197
POKE 23606,80
PRINT AT fil,col+(z/2) ; OVER 1 ; X$(z+1)
END IF
IF z+col > 31 THEN
LET col = 0
LET fil = fil + 1
END IF
NEXT z
POKE 23606,0
POKE 23607,60
RETURN
Aqui les dejo el el .z80 en spectrum basic, el cual funciona a la perfeccion
http://www.mediafire.com/?e1331ilv7wa7k42
el siguiente es el archivo .TAP generado por el compilador del codigo escrito arriba (se resetea)
http://www.mediafire.com/?nubshu8qjaj1kwa
...y el .BIN que debe cargarse en la direccion 50000 con los graficos
http://www.mediafire.com/?fwar9f2ly17hinm
Gracias Boriel por devolverme a la vida, pues programar despierta en mi energias como solo la musica de BACH lo hace; gracias a todos, espero respuestas
|
|
|
| FASTCALL warnings |
|
Posted by: einar - 2012-07-19, 10:43 PM - Forum: Wishlist
- Replies (7)
|
 |
Hi,
Whenever compiling any ZX BASIC program that uses the latest BIFROST* interface library, it will always produce the following warnings:
Code: bifrost.bas:92: warning: FUNCTION 'BIFROSTfindAttr' declared as FASTCALL with 2 parameters
bifrost.bas:177: warning: SUB 'BIFROSTshowTile' declared as FASTCALL with 3 parameters
bifrost.bas:201: warning: SUB 'BIFROSTshowTilePos' declared as FASTCALL with 2 parameters
bifrost.bas:231: warning: SUB 'BIFROSTfillTileAttr' declared as FASTCALL with 3 parameters
In general, these warnings are very useful to notify the user about possible problems on the code. But in the cases when they were already validated (such as above where FASTCALL is used intentionally for performance reasons), they become a disadvantage: the user will always see warnings in every compilation and will soon start to ignore them completely, thus not paying attention anymore to new warnings that may appear about real problems in his/her own code.
I suggest a new directive to allow ignoring such warnings inside an specific library. The idea is that a library file could use something like this:
Code: #pragma push(fastcall_warning)
#pragma fastcall_warning = false
...
#pragma pop(fastcall_warning)
Makes sense?
|
|
|
| not sure what it is bug/feature/me |
|
Posted by: frisian - 2012-06-29, 09:21 PM - Forum: Help & Support
- Replies (2)
|
 |
First something easy I spotted in DRAW.ASM, there are two EQU's that point to the same address
Code: LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
and
PIXEL_ADDR EQU 22ACh
one of those two can be removed.
The program I work on I typed in long ago (needless to say it contains typo's in the data) you can find a copy in WOS it's called PIANOLA.
http://www.worldofspectrum.org/infoseeki...id=0008549
In trying to speed up this program i ran into some problems. The program plays music by machine code, the information is transferred by means of reading data into a string. Compiling the hole program is not my intention,
but some drawing and printing to the screen can surly be sped up by compiling that part.
There is a difference in ZX Basic and the Compiler in handling float's in the PLOT and DRAW statements.
It draws 2 figure's with the help of following code
Code: 2030 FOR i=8 TO 215 STEP 207
LET p=30
LET q=0
LET c=COS (14*PI/p)
LET s=SIN (14*PI/p)
PLOT i,132
FOR b=1 TO 30
DRAW INK 1;p,q
LET p=p*c-s*q
LET q=(p*s+q)/c
NEXT b
NEXT i
I converted it into
dim p,q,c,s as float ' need to use float, fixed screws up totally
dim b as byte
dim i as integer
2030 FOR i=8 TO 215 STEP 207
LET p=30
LET q=0
LET c=COS(14*PI/p)
LET s=SIN(14*PI/p)
PLOT i,132+16 ' +16 to get the same position
FOR b=1 TO 30
DRAW INK 1;p,q
LET p=(p*c)-(s*q)
LET q=(p*s+q)/c
NEXT b
NEXT i
Both give a different figure. It took me some days before I figured out that the calculations in the compiled version where correct, converting the float into a integer screwed things up.
1. first add .5 (round off the number)
2. INT must work like in ZX Basic (3.9 gives 3, -3.9 must give -4)
Code: dim p,q,c,s as float
dim b as byte
dim x,y,i as integer
2030 FOR i=8 TO 215 STEP 207
LET p=30
LET q=0
LET c=COS(14*PI/p)
LET s=SIN(14*PI/p)
PLOT i,132+16 ' +16 to get the same position
FOR b=1 TO 30
LET x = INT(p+.5-(p<0)) ' must use strict-bool, works correct in this case because there is never a number+.5 that equals a integer
LET y = INT(q+.5-(q<0))
DRAW INK 1;x,y
LET p=(p*c)-(s*q)
LET q=(p*s+q)/c
NEXT b
NEXT i
This code will give the same figure as ZX Basic.
I think a closer look into how ZX Basic works using float's in PLOT and DRAW and how the are converted to integers is needed
Now my code compiled without error and it's output looked like the normal basic version. The final piece of code.
Code: dim p,q,c,s as float
dim melo,b as byte
dim x,y,i,t as integer
const p1 as byte = 8
border 5
paper 6
2020 CLS
melo = peek (byte,50900) 'if haven't worked out a better place for this yet
PRINT AT 2,7; BRIGHT 1;"WE PROUDLY PRESENT"
PLOT 55,151+16
DRAW 145,0
DRAW 0,9
DRAW -145,0
DRAW 0,-9
DRAW 2,-2
DRAW 145,0
DRAW 0,9
DRAW -2,2
2025 FOR i=7 TO 18
PRINT PAPER 0;AT i,0;" ";AT i,26;" "
NEXT i
PRINT PAPER 0;AT 19,0,,,,,,
2030 FOR i=8 TO 216 STEP 208
LET p=30
LET q=0
LET c=COS(14*PI/p)
LET s=SIN(14*PI/p)
PLOT i,132+16+1
FOR b=1 TO 30
let x = int(p+.5-(p<0))
let y = int(q+.5-(q<0))
DRAW INK 1;x,y
LET p=(p*c)-(s*q)
LET q=(p*s+q)/c
NEXT b
NEXT i
2040 rem LET p=8 'rename p to p1 and made it a constant
PRINT OVER 1;AT 18,6;"\..\..\..";AT 18,23;"\..\..\.."; INK 2;AT 6,0;"\..\..\..\..\..\..";AT 6,26;"\..\..\..\..\..\..";AT 15,0;"\::\::\::\::\::\::";AT 15,26;"\::\::\::\::\::\::";AT 18,9;"\..\..\..\..\..\..\..\..\..\..\..\..\..\.."
2045 FOR i=1 TO 5
let h$=" "
let f$=" "
if i=3 then let h$="BACH" : let f$="BEAT" : end If
if i=5 then let h$=" " : let f$=" " : end if
PRINT OVER 1; BRIGHT 1; INK p1; PAPER 4;AT i,1+(i=5);h$;AT i,27+(i=5);f$
next i
2050 PLOT 204,28+16
DRAW 0,104
PLOT 207,28+16
DRAW 0,104
DRAW -80,0,.3
DRAW -79,0,.3
DRAW 0,-104
PLOT 51,28+16
DRAW 0,104
PLOT INK p1;127,28+16
DRAW INK p1;0,104
2055 FOR i=9 TO 15 STEP 2
PRINT AT i,p1;"\e\g \h\g";AT i+1,p1;"\f \g\h \h";AT i,18;"\e \h\h \h";AT i+1,18;"\f\g \g \h"
NEXT i
2060 FOR i=61 TO 141 STEP 80
FOR b=98 TO 50 STEP -16
FOR t=0 TO -p1 STEP -2
PLOT i,b+t+16
DRAW 58,0
NEXT t
DRAW 0,p1
PLOT i,b-p1+16
DRAW 0,p1
NEXT b
NEXT i
2070 PRINT AT 17,9;"= ";melo-1;" =";AT 17,18;"= ";melo-1;" =";AT 20,10; BRIGHT 1; INK 7; PAPER 1;"SPECTRUM&SONS"
2080 PRINT AT 22,0;paper 5;bright 1;"\d \d\d \d\d\d \d\d \d\d\d \d\d \d\d\d \d\d \d\d\d \d\d"; ink 7 ;"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
The compiled piece of code worked but it corrupted something so the running of the normal basic part was not what it should be.
First I load the program, RUN, the program loads the two piece of machine code and runs normal until it returns from the first time it used the compiled code, it then needs to print the title of the music piece on the screen, but here go things wrong, instead it prints what looks likes a piece of listing from the basic program, it seems that some where something is corrupted.
But now comes the weird part, if I BREAK the program and let it RUN without loading the two pieces of machine code, it works as it should with out a problem. :?:
I have tried out something, and found at last the line that causes the problem.
If I REM this line out
PRINT OVER 1; BRIGHT 1; INK p1; PAPER 4;AT i,1+(i=5);h$;AT i,27+(i=5);f$
there is no problem, or replacing f$ and h$ with " " will also work.
The problem seems to be with f$ and h$ or I am doing something wrong. (I rewrite the code, now I know what will work)
Sorry for the somewhat long posting.
Regards
Frisian.
|
|
|
| import confusion |
|
Posted by: slenkar - 2012-06-28, 04:23 AM - Forum: Help & Support
- Replies (4)
|
 |
I like having my pathfinding code in a seperate file,
BUT the pathfinding code has to use an array from main.bas
I get error message saying
identifier 'UnitExists' is a function, not a var
but really its an array
I could put Dim UnitExists in the pathfinding.bas file
but what if another included file needs to reference UnitExists?
UnitExists needs to be 'global' somehow
|
|
|
| function INT not working correctly |
|
Posted by: frisian - 2012-06-20, 10:17 PM - Forum: Bug Reports
- Replies (2)
|
 |
I recently discovered ZX Basis Compiler and this forum and it brought back some memories off the days that i owned and used a ZX Spectrum (48k and later a 128k) . I have collected some emulators over the years so i tried to compile some programs, one off witch made a little drawing using some calculation, it look a little different from the normal basic version.
It comes down to converting a float to a integer.
INT 3.9 gives 3 in normal basic and compiled
INT -3.9 in normal basic this is -4 but compiled the answer is -3
The correct answer is -4 according to the ZX basic manual (and also according other programming languages )
I tried zxb .exe version 1.2.9-s758 and zxb version 1.2.9-s882
this problem also occurrence with CAST(integer,float)
Regards
|
|
|
|