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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 259
» Latest member: DonaldDeade
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

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

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

 
  Reading files from disk
Posted by: na_th_an - 04-28-2011, 10:14 AM - Forum: How-To & Tutorials - No Replies

Maybe this is obvious, but let me ask - is there any way to read a BYTES file from disk (I mean, plan +3 disks) from a program compiled in ZX Basic to RAM? I mean, without having to exit the program and go back to plain BASIC to do so. Maybe through ROM calls? Any info on this would be greatly appreciated. I'd like to design some kind of system to make graphic adventures which load stuff from disk.

Print this item

  IF Nesting problem and +D Emulation (*solved*)
Posted by: LCD - 04-19-2011, 11:42 PM - Forum: Bug Reports - Replies (2)

Code:
    while (a band 16)=0
        h=a band 5
        v=a band 10
        if oldh=4 then
            if h=5 then newx=x+1
            elseif h=0 then newx=x-1
            end If
        else if oldh=5 then
            if h=1 then newx=x+1
            elseif h=4 then newx=x-1
            end If
        else if oldh=1 then
            if h=0 then newx=x+1
            elseif h=5 then newx=x-1
            end If
        else if oldh=0 then
            if h=4 then newx=x+1
            elseif h=1 then newx=x-1
            end If
        end If
    wend
The compiler does not like this, and revolts against WEND (should it not work?), but after removing some IFs this works:
Code:
    while (a band 16)=0
        h=a band 5
        v=a band 10
        if oldh=4 then
            if h=5 then newx=x+1
            elseif h=0 then newx=x-1
            end If
        end If
    wend

And I also noticed that one of my games crahes the Spectrum if ZX Spin is started with enabled +D emulation. Boriel, could you check all your compiler tests with ZX Spin and enabled +D? The game preview of QFJ I sent to you some time ago: If I try to play, the gems cannot be swaped. Without +D Emulation anything works okay.

Print this item

  Paper/Border rerun bug
Posted by: Darkstar - 04-12-2011, 10:34 PM - Forum: Bug Reports - Replies (5)

Code:
10 BORDER 4
20 CLS
30 PRINT AT 1,9;INK 3;"Hello World from Assi";
40 END

Hi,

The above code gives green paper with a magenta in ink in the text
message when run the second time from the BASIC loader.

Print this item

  DIM x as String = ?
Posted by: LTee - 04-07-2011, 12:36 PM - Forum: Wishlist - Replies (3)

Hi everyone!

Should this work?

Code:
DIM x as String = "test"

I get the following error when I try to compile:
Code:
Initializer expression is not constant.

Doing this instead is fine:
Code:
DIM x as String: x = "test"

I'm using the latest 1.2.8s696, by the way.

Print this item

  Japan Tsunami Appeal (open ZX firmware)
Posted by: cheveron - 04-04-2011, 08:34 AM - Forum: ZX Basic Compiler - Replies (8)

As some of you will be aware, I've been tinkering with an open source version of SE Basic that could be distributed with hardware without infringing Amstrad's copyright. I'm pleased to say the project is now viable, although it is not yet written.

I've also said I would only release it in exchange for a sack of cash. So let me quantify that: I want 100 people to donate a minimum of £10/€10 each to the Red Cross Japan Tsunami Appeal.

You can sign up here:
http://www.pledgebank.com/opense

If you are based in the UK you can make your donation here:
http://www.redcross.org.uk/Donate-Now/Ma...ami-Appeal

If you are based in Spain you can make your donation here:
http://www.cruzroja.es/portada/

I know it's called pledgebank but I want you to donate now. This is an honour system. If you say you've donated £10/€10 or more I'll assume you have.

Please sign up by July 1st.

Thank you.

-Andrew

P.S. I have donated £10 to get the ball rolling

The total has now reached 17 (13 of which have paid up already). It would be lovely to get to 20 this week. So to encourage you here's a progress report:

* More than 60% of the ROM is now fully functional and unencumbered by Amstrad code.
* The ROM is functionally compatible with SE Basic 2.21 http://www.worldofspectrum.org/infoseeki...id=0025327
* As far as I can tell, everything that ran on the 2.21 ROM still works.
* New RENUM routine. It only accepts the first two parameters, but it isn't broken either.
* New tokenizer. You can now enter INK and it will automatically be translated to PEN.
* 60 abbreviated commands:

Code:
A.TTR           ED.IT           LO.AD           RA.NDOMIZE
BE.EP           ER.ASE          ME.RGE          RE.AD
B.IN            E.XP            M.OVE           REN.UM
BO.RDER         FL.ASH          NE.XT           RES.TORE
BR.IGHT         F.ORMAT         N.OT            RET.URN
CH.R$           GOS.UB          ON.ERR          R.ND
CI.RCLE         G.OTO           OP.EN#          SA.VE
CLE.AR          I.NK            OV.ER           S.CREEN$
CL.OSE#         INKE.Y$         PA.PER          SO.UND
C.ODE           INP.UT          PAL.ETTE        ST.R$
CON.TINUE       INV.ERSE        PAU.SE          T.AB
DA.TA           L.EN            PE.EK           TH.EN
D.EFFN          LI.NE           PL.OT           U.SR
DEL.ETE         LL.IST          P.OINT          V.AL$
DR.AW           LP.RINT         PR.INT          VE.RIFY
* Macros for the following tokens:
Code:
LOAD, CODE, RUN, SIN, COS, TAN, ASN, ACS
* INSERT ([G]) mode now has it's own cursor (an I beam)

Thanks again to everyone who has already contributed.

Print this item

  Memory Management
Posted by: britlion - 03-31-2011, 09:48 AM - Forum: Wishlist - Replies (16)

Why not just put your org lower, have your low non speed critical functions, use align to hop to 32768 and stick a defs 6912, 0 to skip your screen buffer zone?

Print this item

  A For-Next bug in 1.2.8-s682
Posted by: Darkstar - 03-29-2011, 06:24 PM - Forum: Bug Reports - Replies (13)

This works:

Code:
For i = AttrAddress to AttrAddress + NumberOfCells - 1
  Poke i, AttrColor
Next i

This does not:

Code:
For AttrAddress = AttrAddress to AttrAddress + NumberOfCells - 1
  Poke AttrAddress, AttrColor
Next AttrAddress

This would work in other dialects.

Thanks,

Darkstar

Print this item

  A string bug in 1.2.8-s682 (*solved*)
Posted by: Darkstar - 03-29-2011, 01:17 AM - Forum: Bug Reports - Replies (12)

This does not work:

Code:
#Include "alloc.bas"
Declare function String$ (ByVal NumberOfChars as ubyte, ByVal Char as string) as string
Declare sub PlayScrBasic (byval SkyColor as ubyte)

Ink 7: Paper 0: Flash 0: Bright 1: Over 0: Inverse 0: Border 0: Cls
Print "Hello"

Const Black as ubyte = 0
Const Blue as ubyte = 1
Const Red as ubyte = 2
Const Magenta as ubyte = 3
Const Green as ubyte = 4
Const Cyan as ubyte = 5
Const Yellow as ubyte = 6
Const White as ubyte = 7

PlayScrBasic (Cyan)
End


Function String$ (ByVal NumberOfChars as ubyte, ByVal Char as string) as string

'Dim Chars$ as string

'Dim CharPtr as uinteger
'Dim CharsPtr as uinteger
'Dim CharsPtrDeallocate as uinteger
'CharStr
'NumberOfChars = NumberOfChars + 1
'CharsPtr = Allocate(NumberOfChars)
'Dim CharStr as string at @CharP


''CharP = @Char$
'Return "x" '@Char$

Dim i as ubyte

For i = 1 to NumberOfChars
  Chars$ = Chars$ + Char$
Next i

Return Chars$

End Function

sub PlayScrBasic (byval SkyColor as ubyte)

Dim i as ubyte
Dim Space32$ as string
Space32$ = String$(32, " ")

cls
Paper SkyColor
If SkyColor <> 0 then
  fOR i = 0 TO 12
    'Print at i, 0; String$(32, " ")
    Print at i, 0; Space32$
  Next i
End if
Space32$ = ""

Paper Green
Print at 11, 6; String$(21, " ")

FOR i = 8 TO 21
  Paper Red
  Print at i, 5; " "
  IF i > 11 THEN
    Print at i,5; String$(22, " ")
    IF i > 12 AND i < 21 THEN
      Paper Blue
      Print at i, 0; String$(5, " ")
      Print at i, 27; String$(5, " ")
    End if
  End if
Next i

Paper Yellow
Print at 21, 0; String$(5, "Û")
Print at 21, 27; String$(5, "Û")
Paper Black

end sub

However if I rem out everything that has Space32$ in it and unrem:
'Print at i, 0; String$(32, " ")'
Then it works fine and heap size does not seem to matter. If I press break
and restart the program then it fails on the second run even though it
works fine the first time if I make the changes noted above.

My bat file to compile this is as follows:
@echo off
if exist GAME.TAP del GAME.TAP
zxb Invasion.b --optimize=0 --output=GAME --tap --BASIC --autorun --org=39680 --array-base=0 --string-base=0 --heap-size=1280 --strict-bool --enable-break
ren GAME GAME.TAP

I do not trust this string handling and it would be nice to have a inbuildt
String$(NumChars, Char$) function.

Thanks,

Darkstar.

Print this item

  Sound effects?
Posted by: LTee - 03-25-2011, 08:48 AM - Forum: How-To & Tutorials - Replies (21)

Can anyone suggest how I could make some half-reasonable beeper sound effects? My initial experiments with BEEP are.... uninspiring. :-D

I was wondering if there was a tool or something that I could use to create some snazzier effects and then somehow integrate those into my ZXBasic setup? Or are there any tricks that people use to get more out of BEEP?

Thanks!

Print this item

  What's wrong with this code?
Posted by: LTee - 03-24-2011, 02:14 PM - Forum: Help & Support - Replies (4)

Okay, this is driving me mad. :-D

I wrote a little routine to 'shuffle' the numbers 1 to 10 into an array, randomly. It's not exactly the best way of doing this but it was supposed to be a quick test. Regardless, it doesn't work. Or rather, it does work - the first time you run it. The second loop of the same code never completes and I can't decide if I found a bug or if I've made a mistake.

Here's the code:

Code:
dim levelMap(10) as UBYTE

randomize
for x = 1 to 10
    cls
    generateLevelMap()
    for n = 1 to 10: print levelMap(n): next n
    pause 0
next x

SUB generateLevelMap()
    dim lm as UBYTE
    dim lmPos as UBYTE = 0
    
    'clear the map first
    for lm = 1 to 10
        levelMap(n) = 0
    next lm
    
    'debug code to print the map, to make sure it's empty
    print
    for lm = 1 to 10
        print levelMap(n);",";
    next lm
    print
    pause 0
    
    'now fill it randomly
    print
    for lm = 1 to 10
        do
            'get a random position in the array
            lmPos = int(rnd * 10) + 1
            
            'debug code to print the number we randomly picked
            print lmPos;",";
            
            'debug code to print the array element if it ISN'T empty
            if levelMap(lmPos) <> 0 then
                print ink 2;levelMap(lmPos);",";
            end if
            
        loop until levelMap(lmPos) = 0
        
        'write the current number into the empty random element
        levelMap(lmPos) = lm
        
        'debug code to show that we handled this number okay
        print inverse 1;lm
        
    next lm
    
    pause 0
    cls
END SUB

I've stuck a load of debug info in there so that you can see what it's doing.

Basically it does this:
1. Clear the array to all zeroes
2. For each number, 1 to 10....
3. Look in a random array position to see if it's zero.
3a. if it isn't, loop around to 3 and try a different one
3b. if it is, write the number into that array position and move on to the next number
4. The result should be the numbers 1 to 10 in a random order in the array, after a variable number of iterations.

First run, no problem.

Second run, although the debug code shows that the array was cleared, the do...loop until loop never completes - by the time it's checking the array within that loop it contains the OLD values again, despite me having zeroed them out just a few seconds earlier.

Am I missing an obvious goof? :-D

Print this item