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: Jbizzel
» Forum threads: 955
» Forum posts: 6,007

Full Statistics

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

Latest Threads
Testing a variable within...
Forum: Help & Support
Last Post: RandomiserUsr
03-25-2022, 09:59 PM
» Replies: 11
» Views: 1,560
WHILE Loop vs FOR/NEXT Lo...
Forum: Help & Support
Last Post: RandomiserUsr
03-25-2022, 09:55 PM
» Replies: 2
» Views: 427
The Disputed Territories ...
Forum: Gallery
Last Post: Jbizzel
03-21-2022, 05:29 PM
» Replies: 0
» Views: 201
The sound effect thread
Forum: How-To & Tutorials
Last Post: worcestersource
02-23-2022, 02:22 PM
» Replies: 3
» Views: 641
mine sweeper
Forum: Gallery
Last Post: Jbizzel
02-22-2022, 02:17 PM
» Replies: 2
» Views: 593
Kardinal Kid - new game i...
Forum: Gallery
Last Post: Jbizzel
01-30-2022, 10:25 PM
» Replies: 2
» Views: 555
Frogger 50
Forum: Gallery
Last Post: boriel
01-23-2022, 08:21 PM
» Replies: 2
» Views: 614
snake game
Forum: Gallery
Last Post: boriel
01-21-2022, 08:23 PM
» Replies: 1
» Views: 499
Problem with compiling ga...
Forum: Help & Support
Last Post: boriel
12-29-2021, 10:02 PM
» Replies: 1
» Views: 654
ZXBC to target 128K BIOS ...
Forum: Help & Support
Last Post: RandomiserUsr
12-28-2021, 01:42 PM
» Replies: 2
» Views: 700

 
  ORG 60000 - LEN(compiled code)
Posted by: zarsoft - 12-03-2021, 09:54 AM - Forum: ZX Basic Compiler - Replies (1)

Hi
I want to put the code on top memory.
How do I know the length of the compiled code?

Print this item

  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
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: 160)

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