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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 258
» Latest member: manuelzo75
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

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

Latest Threads
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 186
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 258
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 1,521
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 512
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 414
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 286
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 1,013
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 2,852
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 394
ZXodus][Engine
Forum: ZX Basic Compiler
Last Post: boriel
02-19-2025, 11:43 PM
» Replies: 69
» Views: 213,482

 
  for without next error
Posted by: maeloterkim - 10-10-2021, 02:22 PM - Forum: Help & Support - Replies (3)

Hi

I found that if i dont write a  next in a for the compiler only says "error: Unexpected end of file"

pointing to the LAST LINE  of the program

if i only have a few lines is "easy" to find the error

but if i have 2000 or more lines is a crazy thing to find the error

Can the compiler add a rule to search if every FOR have a NEXT and throw the error  "for without next" ?

This way is more easy to find the error in a BIG program with a lot of lines

You can look the example code



''EXAMPLE CODE WITH EXPLAINED ERROR

dim example as uByte = 0

for example = 0 to 10

    print example

'' THE NEXT MUST GO HERE IN LINE 9 but the compiler logically dont know that
'' BUT Can the compiler say  "error: for without next"
'' instead of "19: error: Unexpected end of file" ?
'' because if we have 2000 or more lines
'' and we dont know what happens
'' is a crazy thing search that error


print "end of program"

Print this item

  BASIC FROGGER
Posted by: maeloterkim - 10-04-2021, 10:14 PM - Forum: Gallery - Replies (5)

After all the hacking questions about the compiler i ended the game and is presented to bytemanicos contest

The game is BASIC FROGGER

Enjoy the attached file basicFrogg.tap



Attached Files
.tap   basicFrogg.tap (Size: 45.91 KB / Downloads: 5)
Print this item

  not updating the DF CC variable
Posted by: maeloterkim - 10-01-2021, 08:46 AM - Forum: Help & Support - Replies (3)

Hi

In the original ZX spectrum basic when you PRINT something the variable DF CC is updated with the screen position

for example the next program must print 16384 that is the first position of the screen

but the only answer always with every diferent position is 16448

this means that the print routine is not updating the DF CC variable like the original ROM

Is this a bug?

You can try this program and change the coordinates of the first print 0,0

Code:
dim myScreen as uInteger

print at 0,0; 
myScreen = peek (uInteger, 23684)  '' 23684 = DFCC = Must be screen position after every print
print at 10,10; myScreen

Print this item

  zx0 compression corruption on decompressing (solved)
Posted by: RandomiserUsr - 09-29-2021, 06:50 PM - Forum: Bug Reports - Replies (3)

Since zxbc.py 1.15.3-beta9 the following is causing screen corruption

dzx0Standard(@Pic1, 16384)

Pic1:
asm
incbin "pic1.scr.zx0"
end asm

The same thing happens for text uncompressing.

See attachments for all of the files.

The same code works fine on 1.15.2 stable

Thanks

.zip   zx0picbug.zip (Size: 2.75 KB / Downloads: 663)

Print this item

  is possible a variable goto or gosub?
Posted by: maeloterkim - 09-27-2021, 01:50 PM - Forum: Help & Support - Replies (3)

Hi

in the original  ZX spectrum basic you can do this

goto MyVariable  or gosub MyVariable  where this variable must be a line number

this way we can goto or gosub to diferents routines that are in diferents line numbers

but i tried this example with the compiler and says error: Syntax Error. Unexpected token 'MyRoutines' <ARRAY_ID>

This is the example you can try:


dim MyRoutines(2) as uInteger => {  @MyRoutine1, _    '' address of my routine 1
                                                       @MyRoutine2, _    '' address of my routine 2
                                                      @MyRoutine3 _    '' address of my routine 3
                                                  }
                               
dim myVariable as uByte = 1

gosub MyRoutines(myVariable)     '' you can try goto too


myLoop:
goto myLoop


MyRoutine1:
print "MyRoutine 1"
return                   

MyRoutine2:
print "MyRoutine 2"
return                   

MyRoutine3:
print "MyRoutine 3"
return       


Is possible do something like that without a lot of ifs ?


I think i found a solution

The solution i found is this:


dim MyRoutines(2) as uInteger => { @MyRoutine1, _ '' address of my routine 1
@MyRoutine2, _ '' address of my routine 2
@MyRoutine3 _ '' address of my routine 3
}

dim myVariable as uByte = 0


poke uInteger (@pokeGosub1 + 1), MyRoutines(myVariable)

pokeGosub1:
gosub MyRoutine1


myLoop:
goto myLoop


MyRoutine1:
print "MyRoutine 1"
return

MyRoutine2:
print "MyRoutine 2"
return

MyRoutine3:
print "MyRoutine 3"
return


I do a poke with the routine direction just before the gosub

maybe you can implement this with the compiler

this way the behaviour is more like the original ZX spectrum Smile

Print this item

  DEFADD trick with ZX BASIC compiler?
Posted by: maeloterkim - 09-22-2021, 07:45 PM - Forum: Help & Support - Replies (1)

Hi

In the normal basic of zx spectrum 48k there is a behaviour or trick like this

you can change the address of DEFADD variable

and after this you can copy bytes very fast  Is like an assembler LDIR

I will explain more

you can have 2 variables A$ and B$  for example

every one of this variables can have 1000 bytes

when you do A$ = B$  the 1000 bytes of B$ are copied on A$

Normally DEFADD points to the beginning of the variables definitions

for example  (invented numbers)

DEFADD_POINTER_ADDRESS    ;;'' defadd initial definitions of variables
A$ begins on 30000 and have 1000 bytes of size
B$ begins on 32000 and have 1000 bytes of size
etc ...


The trick is that in BASIC we can change the DEFADD address and put any thing

for example we can do

CHANGED_DEFADD_POINTER_ADDRESS    ;;'' CHANGED defadd initial definitions of variables
A$ begins on 16384 and have 256 bytes of size
B$ begins on 32000 and have 256 bytes of size
etc ...


This way we can do A$ = B$ and copy 256 very fast to the screen !!!

this is better explained here in spanish
https://blog.jafma.net/2020/03/16/effici...m-iv/#sp_5

and here in english
https://blog.jafma.net/2020/03/16/effici...m-iv/#en_5

and here a video in spanish explaining this trick
https://www.youtube.com/watch?v=VKJ2dePykdA

I tried this trick with compiled zx basic but is not working because seems
that string variables are not doing the same behavior that original ROM

Print this item

  Is there a list somewhere that explains how to optimize?
Posted by: maeloterkim - 09-15-2021, 06:19 AM - Forum: Help & Support - Replies (2)

Hi

Is there a list somewhere that explains how to optimize?

i  explain

Normally in compilers if you put the code in one way it is more efficient than if you put the code in another way

For example you can do

variable ++    or   variable = variable + 1

or maybe if you use local variables it is more efficient than if you use global variables

perhaps the compiler translates with fewer bytes and more efficiently one way or another

Is there somewhere a recomended list of tricks to write a more efficient syntax that translates better to assembler

and uses less memory and fewer bytes?

Print this item

  warning: [W180] Unreachable code problem?
Posted by: maeloterkim - 09-10-2021, 06:17 PM - Forum: Bug Reports - Replies (5)

Hi  if i compile this, says

warning: [W180] Unreachable code

but i don't know why


the version is  zxbasic-1.15.2





Code:
' EXAMPE UNRECHABLE CODE

declare sub mySub()

Dim myNumber As uByte
cls

myBucle:
    for myNumber = 0 to 7          
        mySub()                  
    next myNumber
    goto myBucle

sub mySub()

end sub

Print this item

  why is there 2 halt on waitretrace macro?
Posted by: maeloterkim - 09-09-2021, 06:02 PM - Forum: Help & Support - Replies (1)

why is there 2 halt on waitretrace macro?

i found in the library this waitretrace macro in the  retrace.bas  file

REM simple WaitRetrace macro

#ifndef waitretrace
#define waitretrace 'REM Retrace \
asm \
halt \
halt \
end asm

#endif


Is not better put only one halt for better timer control of the programmer?

if there was only one halt is more easy to control

with one halt we can do

waitretrace  ->  only 1 halt  1/50 seconds

2 halt      -> 2/50seconds
waitretrace   
waitretrace    

N halt    -> N/50seconds
for i = 1 to N
   waitretrace
next i

Print this item

  It is possible to read the state of the flags with basic
Posted by: maeloterkim - 09-07-2021, 03:12 PM - Forum: Help & Support - Replies (2)

Hi  Smile

In assembler there is a register that have the state of the flags zero, carry , etc

It is possible to read the state of the flags ONLY WITH BASIC (NOT ASSEMBLER) or the state of the carry flag, zero flag etc

Print this item