Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 147 online users. » 0 Member(s) | 145 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: 325
|
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,601
|
Creating +3 Menus - Loadi...
Forum: Help & Support
Last Post: merlinkv
04-16-2025, 02:08 PM
» Replies: 6
» Views: 557
|
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,811
|
|
|
Using ZXbasic to add page banked IM music |
Posted by: emook - 02-18-2017, 11:43 AM - Forum: Gallery
- Replies (1)
|
 |
Hi,
As a small challange I wanted to see if I could add music to games written with ADG by Jonathan Caudwell. ADG games usually take around 30k of memory starting from around 32000 so this leaves no room for music and playback.
My idea was that I would swap in bank 4 (@49152) and set up my music and then an IM routine at 25500. The IM routine swaps to bank 4, plays a frame of music and swaps the bank back to 0 and allows the game to continue. Here's the code I came up with (the music routine and data have been compressed with zx7 to take up less space)
An working example can be seen here with : http://torinak.com/qaop#128#l=http://zxbasic.uk/uploads/monty_tls.z80
Code: #include <memcopy.bas>
' REM IM music for ADG v1
' monty
border 0
paper 0
ink 6
cls
ASM
di ; disable intsd
LD A,(23388)
AND 248
OR 4 ; select bank 4
LD BC,32765
LD (23388),A
OUT (C),A
EI
END ASM
' the playsoutine expects the music to be at 51310, so lets copy the music there
zx7Unpack(@music, 51310)
' The play routine expects to be at 49152, so lets copy it there
zx7Unpack(@ayplay, 49152)
' This is routine that will be called every frame, lets copy it to its correct location
memcopy(@Ints, $6060, 60)
' we need to init our play routine, so call it
randomize usr 49152
randomize USR @IMStart
' Start ADG game
'randomize usr 32000
END
ayplay:
asm
incbin "vt49152.bin.zx7"
END asm
music:
asm
incbin "intro.pt3.zx7"
END asm
musicend:
Ints:
asm
di ; disable interrupts
push af ; save all std regs
push bc
push de
push hl
push ix
push iy
ex af, af' ; and shadow af
push af
; swap to bank 4
LD A,(23388) ; load a with previos port value
AND 248
OR 4 ; bank 4
LD BC,32765
LD (23388),A
OUT (C),A
call 49157 ; play the current tune
;swap back to bank 0
LD A,(23388)
AND 248
OR 0
LD BC,32765
LD (23388),A
OUT (C),A
pop af
ex af, af' ; restore af
pop iy
pop ix ; restore ix & iy
pop hl
pop de
pop bc
pop af ; restore all std regs
ei ; enable interrupts
jp 56
END asm
IMStart:
asm
DI
; swap to bank 4 before IM start
LD A,(23388)
AND 248
OR 4
LD BC,32765
LD (23388),A
OUT (C),A
; this code creates a 256 byte vector table at $FE00, then sets IM2
ld hl, $5e00
ld de, $5e01
ld bc, 256
ld a, h
ld i, a
ld a, $60
ld (hl), a
ldir
im 2
; now swap back to 0
LD A,(23388)
AND 248
OR 0
LD BC,32765
LD (23388),A
OUT (C),A
ei
ret
END asm
IMOff:
ASM
DI
IM 1
EI
RET
END ASM
|
|
|
How can I use ZXB as Assembler only |
Posted by: Luzie - 02-13-2017, 09:28 PM - Forum: How-To & Tutorials
- Replies (2)
|
 |
I want to use ZXB "as Assembler only". So no single BASIC statement will be used.
E.g. I just want to assemble this:
ASM
ORG 50000
RET
END ASM
and after compiling this should result in just a .BIN or .TAP-File which contains the single $C9 mcode ($C9=201 dez for RET) and is in memory from adress 50000 dez.
Is there a simple way for doing this?
|
|
|
Compounded Let statments |
Posted by: emook - 02-02-2017, 01:17 PM - Forum: ZX Basic Compiler
- Replies (6)
|
 |
Hello,
I've noticed that somthing that is possible is Sinclair Basic doesn't seem possible in Boriel....
eg:
Sinclair Basic
10 LET x=0
20 LET x=x+1-(50 AND x=50)
30 PRINT AT 0,0;x,
40 GOTO 20
As you can see x=x+1 will increment minus 0 unless x=50 then it will subtract 50. Great for loops and counters. In ZXB I am having to expand this into IF THEN statements.
x=0
x=x+1
myloop:
IF x=50 THEN
x=0
END IF
Print at 0,0;x,
GOTO myloop
|
|
|
Reading Kempston Joystick using function IN 31 |
Posted by: Luzie - 01-08-2017, 09:45 PM - Forum: How-To & Tutorials
- Replies (4)
|
 |
Hi,
I´m missing the IN function in ZX BASIC (as it was in Original Sinclair ZX Spectrum BASIC).
Would like to use it as described here:
<!-- m --><a class="postlink" href="https://chuntey.wordpress.com/2010/01/06/using-kempston-joystick-in-your-own-basic-programs/">https://chuntey.wordpress.com/2010/01/0 ... -programs/</a><!-- m -->
Must I use some machine code emulate?
If so, can someone please post me an example?
Regards,
Luzie
|
|
|
compiler error (unicode argument expected) |
Posted by: slenkar - 01-02-2017, 01:29 AM - Forum: Bug Reports
- No Replies
|
 |
Traceback (most recent call last):
File "/root/Downloads/zxbasic/zxb.py", line 348, in <module>
sys.exit(main(sys.argv)) # Exit
File "/root/Downloads/zxbasic/zxb.py", line 339, in main
output(asm_output, fout)
File "/root/Downloads/zxbasic/zxb.py", line 72, in output
ofile.write('\t')
TypeError: unicode argument expected, got 'str'
EDIT- oh it was because I needed 1.3.0
I was using 1.2.9 so problem solved!
|
|
|
|