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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 260
» Latest member: Ra001
» Forum threads: 1,073
» Forum posts: 6,437

Full Statistics

Online Users
There are currently 316 online users.
» 0 Member(s) | 314 Guest(s)
Baidu, Bing

Latest Threads
Strange Happenings
Forum: Bug Reports
Last Post: boriel
05-23-2025, 09:15 AM
» Replies: 4
» Views: 1,836
.tap file code not execut...
Forum: Help & Support
Last Post: Zoran
04-28-2025, 10:59 AM
» Replies: 4
» Views: 2,022
Exit from more than one l...
Forum: Wishlist
Last Post: Duefectu
04-23-2025, 10:06 PM
» Replies: 3
» Views: 1,684
put small ASM programs li...
Forum: How-To & Tutorials
Last Post: Zoran
04-18-2025, 02:02 PM
» Replies: 6
» Views: 4,075
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 2,827
Randomize not very random...
Forum: Help & Support
Last Post: Zoran
04-08-2025, 10:40 AM
» Replies: 4
» Views: 2,697
Scope rules
Forum: Bug Reports
Last Post: Zoran
04-04-2025, 09:46 AM
» Replies: 2
» Views: 1,445
Using constants not allow...
Forum: Bug Reports
Last Post: baltasarq
03-19-2025, 10:00 PM
» Replies: 8
» Views: 3,619
404 page not found
Forum: Documentation
Last Post: boriel
03-08-2025, 07:16 PM
» Replies: 5
» Views: 4,676
Spectrum keywords codes
Forum: Bug Reports
Last Post: boriel
03-08-2025, 11:00 AM
» Replies: 1
» Views: 1,162

 
  Out of Memory error
Posted by: LCD - 08-28-2011, 08:46 PM - Forum: Help & Support - Replies (12)

I made a snapshot from my game I currently write. On level 4 after 6 moves it came with a out of memory error, but the code is not different from levels 1-3, where it works well. I suspect a memory leak. The included snapshot is just short before it happens (Controls: QAOPM). I can PM the source too. The same thing happen with Heap size 256 or 1500.

.zip   Level4_1.zip (Size: 9.44 KB / Downloads: 1006)

Print this item

  Learning ASM and ZX Basic Compiler
Posted by: oblo - 08-22-2011, 01:57 PM - Forum: Help & Support - Replies (4)

Hi all

I know it's a bit odd to ask this, because the compiler doesn't ask us to learn ASM but...
I'm starting to learn some ASM and besides read some books, I'm trying to get some examples from <!-- m --><a class="postlink" href="http://stu.pido.us/wiki/retrogames:index">http://stu.pido.us/wiki/retrogames:index</a><!-- m --> and <!-- m --><a class="postlink" href="http://members.fortunecity.com/jonathan6/egghead/id2.html">http://members.fortunecity.com/jonathan ... d/id2.html</a><!-- m -->, but every piece of code I try to compile between ASM and END ASM, end with a compiler error, for instance:

Code:
ASM
       ld a,2              ; upper screen
       call 5633           ; open channel
loop   ld de,string        ; address of string
       ld bc,eostr-string  ; length of string to print
       call 8252           ; print our string
       jp loop             ; repeat until screen is full

string defb '(your name) is cool'
eostr  equ $
END ASM

...ends with "temp.bor:11: Error: illegal preprocessor character '$'. Compilation failed" And:

Code:
ASM
; scroll izquierda
;
        ld hl, 22527
        ld c, 192
buc_2   ld b, 32
        and a
buc_1   rl (hl)
        dec hl
        djnz buc_1
        jr nc, noca_1
        ld (var), hl
        ld ix, (var)
        set o, (ix+32)
noca_1  dec c
        jr nz, buc_2
        ret
;
; scroll derecha
;
        ld hl, 16384
        ld c, 192
buc_4   ld b, 32
        and a
buc_3   rr (hl)
        inc hl
        djnz buc_3
        jr nc, noca_2
        ld (var), hl
        ld ix, (var)
        set 7, (ix-32)
noca_2  dec c
        jr nz, buc_4
        ret
var     equ 23728
END ASM

...ends with "temp.bor:3: Error: Syntax error. Unexpected token 'LD' [LD]. Compilation failed"

Is there any consideration to use ASM code in the compiler, the code examples are wrong... or have I to use another compiler, like PASMO, to compile ASM?

Thanks in advance and cheers

EDIT: I've just found this post (<!-- l --><a class="postlink-local" href="http://www.boriel.com/forum/bug-reports/illegal-preprocessor-errors-on-some-files-solved-t603.html">bug-reports/illegal-preprocessor-errors-on-some-files-solved-t603.html</a><!-- l -->) but I can't manage to solve it Sad

Print this item

  O-Cman
Posted by: oblo - 08-21-2011, 07:59 PM - Forum: Gallery - Replies (11)

Hi All

After a month of developing, I'm proud to release O-Cman, a Pacman clone for the ZX Spectrum. Their main features are:

- A nearly clone of the original arcade.
- Smooth animations
- Each ghost has its own IA
- Sounds, high score and several minor details regarding the original game.

Things that I think can improve the game (but I'm a bit 'lazy' to do them right now)

- Better IA for all the ghost
- Smooth animation for the eyes (I realize it too late)
- Different graphics for 'eatables' ghosts (I realize it too late too)

I hope you enjoy it as much I enjoyed making it. Please, feel free to send any comments, bugs, etc... I'll be grateful to see them Smile

Cheers



Attached Files
.rar   O-Cman_v1.0.rar (Size: 20.19 KB / Downloads: 275)
Print this item

  Initialising an array of addresses
Posted by: LTee - 08-10-2011, 11:25 AM - Forum: Help & Support - Replies (2)

I was trying to keep a list of memory addresses (pointing to tile data) in an array to use as a cheap lookup table. I tried to do something like this:

Code:
'data
Data:
asm
defb 0, 0, 191, 191, 191, 191, 191, 191, 0, 0, 253, 253, 253, 253, 253, 253
end asm

'array of addresses
dim tsAddress(TSMAXTILES) as uinteger => {@Data}

... which doesn't work, because @Data isn't a constant so I get an "Initializer expression is not constant" compiler error.

I could write and call a method which loads the array with the correct information on startup, but I just wanted to check that I wasn't missing an obvious trick which would allow me to avoid that? Thanks for any tips! Smile

Print this item

  Using Beepola with ZX BASIC
Posted by: LTee - 08-09-2011, 09:09 AM - Forum: How-To & Tutorials - Replies (15)

Using Beepola to add tunes to your ZX BASIC projects is actually pretty easy. Beepola is able to export its players and songs as .TAP files, which you can then merge in with your own code and call from ZX BASIC using standard RANDOMIZE USR calls.

Here's a quick how-to:

1. Make your tune. I can't help much with this bit, but I've successfully managed to integrate the Music Box, Phaser1 and Special FX engines into ZX BASIC, so I surmise they will all work. You can download Beepola from here: http://freestuff.grok.co.uk/beepola/

2. Now you need to compile your tune so that it's useful from ZX BASIC. You do this by selecting 'Compile' from Beepola's 'Tools' menu, which pops up a window with some options. The most important thing here is to make sure you set the player and song to use an area of memory which won't interfere with your own program. I tend to set this high in memory (64000 and up), but bear in mind that each player uses a different amount of memory and you'll also need to leave room for your song data. Each player has a different set of options, but basically it's all up to you here - choose whatever's best for your tune and situation.

3. The easiest way to integrate the song and player is to choose to export from Beepola as a .TAP file. I usually choose the 'code block only' option because you're not going to need the BASIC loader. Once that's saved, you need to load your game AND the player into memory at the same time. It's actually pretty easy to automate all of this using batch files (or their equivalent if you're non-Windows), because .TAP files are remarkably easy to join together. During Dex development, I created a BASIC loader which loaded my game code and the music code and saved that as a .TAP file. Then I used a batch 'make' file like this to build and assemble the game into a single .TAP.

e.g. BASIC LOADER (saved as loader.tap)

Code:
10 CLEAR 29999: LOAD "" CODE: LOAD "" CODE: RANDOMIZE USR 30000

e.g. BATCH FILE (saved as make.bat)
Code:
"\program files\zxbasic\zxb.py" dex.bas --output=dexgame.tap --org=30000 -t -Z
copy /b loader.tap + dexgame.tap + DexJingle.tap Dex.tap

The first line of the batch file compiles the game. Once done, the 'copy' command takes the loader, game code and tune and merges them all together into one large .TAP file (called Dex.tap) that I can just double-click and run. Don't forget the /b switch on the copy operation, otherwise the files will be copied as text rather than binary and probably won't work.

4. If your game is to have multiple tunes, you only need to have one copy of the player - you don't need a separate copy of the player for each tune. Each Beepola engine has a couple of POKEable memory addresses near the start of the player code which points to the tune to be played. If you make more than one tune, export those from Beepola as 'song data only' .TAP files. Make sure that you choose the same settings as for your main tune and that you place the song data at a memory location that is away from both your game code AND the first tune's code.

5. During all of these steps, remember to keep track of the memory addresses that you have compiled the music data to. This is rather important as without the addresses you won't know what to call from your game. Including the address in your filenames as a reminder might be a good idea! Smile

6. Once you have everything ready to go, all that's left to do is to call the player from within your own ZX BASIC code. This is actually very simple - just a standard RANDOMIZE USR xxxxx call (where xxxxx is the address you compiled the player to) will do the trick. However, if you're making this call from within a ZX BASIC sub or function block, be aware that you need to preserve the IX register or the Spectrum is likely to crash - more details on this below. If you wish to play one of the 'extra' tunes described in point 4, you'll first need to POKE the relevant memory addresses with the location of the new song data - Beepola's documentation will tell you how to calculate what these addresses are for each individual engine.

7. This all sounds a bit complicated, but it really isn't. It's probably easier to show in an example, so I'll show you how I created my music playing subroutine for Dex. See the code fragment below:

Code:
'some constants
const TUNESON as UBYTE = 1
const TUNEPLAYERADDR as UINTEGER = 64000
const TUNE1 as UINTEGER = 64798
const TUNE2 as UINTEGER = 64850
const TUNE3 as UINTEGER = 64900

const TUNEMAIN as UBYTE = 1
const TUNELEVELSTART as UBYTE = 2
const TUNELEVELEND as UBYTE = 3
const TUNEGAMEOVER as UBYTE = 4

'plays a piece of music
SUB playMusic(tune as UBYTE)
    DIM SongAddr as UINTEGER = 0
    
    'select the correct tune
    if tune = TUNEMAIN then
        SongAddr = TUNE3
    elseif tune = TUNELEVELSTART then
        SongAddr = TUNE1
    elseif tune = TUNELEVELEND then
        SongAddr = TUNE3
    elseif tune = TUNEGAMEOVER then
        SongAddr = TUNE2
    end if
    
    'call the music player
    if TUNESON = 1 and SongAddr > 0 then
        
        'poke the values for the tune start
        poke TUNEPLAYERADDR + 1, SongAddr - 256 * INT(SongAddr / 256)
        poke TUNEPLAYERADDR + 2, INT(SongAddr / 256)
        
        'and play the tune (remember to preserve IX register or it'll crash)
        asm
            push ix
        end asm
        randomize usr TUNEPLAYERADDR
        asm
            pop ix
        end asm
        
    end if
    
END SUB

This routine is basically all of the stuff I described above squashed into a single sub. The main music player was compiled and loaded to 64000, which I've put into a constant. The three tunes I use also have their memory locations described by constants. To play a tune, I call 'playMusic(TUNEMAIN)' (or whatever) and the SUB does all the rest.

You'll see that the address of the tune is determined by the constant I pass - this address is then POKEd into the player engine as described in Beepola's docs. Because we're calling from a SUB, the IX register needs to be preserved - this is easily done with a simple 'push ix' in an ASM block. Once we've done that, it's safe to call the player with 'RANDOMIZE USR'. Once the player returns control to us, we 'pop' the value of IX to allow us to return safely from the subroutine.

Job done!


I hope this is clear, it seems a lot more complicated to write down than it is in my head. If anyone has further questions, please feel free to ask! Smile

Print this item

  IndexError: list index out of range (*solved*)
Posted by: oblo - 08-05-2011, 10:34 PM - Forum: Bug Reports - Replies (6)

Hi all

I'm trying to compile a piece of code but I get the following output:

zxb.exe my_program.bor --org=27000 --heap-size=1024 -t -B -
Traceback (most recent call last):
File "zxb.py", line 312, in <module>
File "zxb.py", line 246, in main
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1035, in traverse
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1040, in traverse
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1035, in traverse
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1035, in traverse
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1035, in traverse
IndexError: list index out of range

What does it means? I'm using 1.2.8s715 version

Cheers

Print this item

  Unexpected end of file error
Posted by: oblo - 07-31-2011, 01:45 PM - Forum: Help & Support - Replies (7)

Hi all

Sorry to bother you twice in the same day :? I'm falling back to the safe land of BASIC but I'm still struggling with problems. I'm getting an "Unexpected end of file. Compilation failed" error. I'm searching for a lost bracket, lost END IF or similar (another post suggests that could be a lost parenthesis but I can't find any). What others symbols/codes/etc must I look for?

I'm compiling with tha last version and with the following options:
zxb.exe oc_UTF8.bor -S 27000 -t -B -a -o oc_UTF8.tap -O 0 --heap-size=1024

Thanks and regards



Attached Files
.rar   oc_UTF8.rar (Size: 3.66 KB / Downloads: 167)
Print this item

  BorIDE ASM compilation error
Posted by: oblo - 07-31-2011, 02:00 AM - Forum: ZX Basic Compiler - Replies (4)

Hi all

I'm trying to compile a piece os ASM in BorIDE. The code is:

ASM
[2746 lines of ASM]
END ASM

When I try to compile it, I always have the same error (check image) The point is that no matter if I add or remove lines from the code, the error is always the same and always in the same line (1917) Anybody know if it's a bug? Maybe there are too many lines of code?

Thanks and regards

EDIT: the error is not generated by BorIDE but the zxb.exe compiler, sorry.



Attached Files
.jpg   Clipboard01.jpg (Size: 33.45 KB / Downloads: 15590)
Print this item

  Dex
Posted by: LTee - 07-21-2011, 12:42 PM - Forum: Gallery - Replies (15)

Thought I'd post a few shots of the game that I've been working on practically forever. It's 99% done, I'd say. Just need that final push to finish the last few things off.

It's a bog-standard 1982-style 'paint the maze' game in an arcade style. Avoid the monsters or sacrifice some of your bonus to make them vanish for a few seconds. Ten different mazes (played out in a random order, in a variety of colour schemes), high score table, three difficulty levels, yada yada yada. Smile

Hope it looks interesting. Smile

[Image: ip5zeu.png] [Image: 5fetj9.png] [Image: euqyv6.png]

Edit: The game is now out! Grab it from WOS: http://www.worldofspectrum.org/infoseeki...id=0026574

Print this item

  New beta release 1.2.8s706
Posted by: boriel - 07-20-2011, 10:49 PM - Forum: Bug Reports - Replies (4)

Okay, a new beta release with an *important* fixes :!:

  • ! Some operations with arrays leaded to corruption and program crash. Fixed. (thks. to Darkstar)
  • ! Fixed a print bug discovered by Compiuter (thks). This also simplifies PRINT routines (shorted and slightly faster).
  • ! Block comments (multiline comments) might crash the compiler and were being incorrectly parsed. Fixed.
  • + Little assembler optimization under some circumstances.
You can download (as always) from <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb">http://www.boriel.com/files/zxb</a><!-- m -->

Print this item