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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 274
» Latest member: zxspecticle
» Forum threads: 1,086
» Forum posts: 6,487

Full Statistics

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

Latest Threads
New video Couse / Nuevo c...
Forum: News
Last Post: Duefectu
2026-04-29, 11:02 PM
» Replies: 0
» Views: 209
location of heap manageme...
Forum: Help & Support
Last Post: boriel
2026-03-07, 12:13 AM
» Replies: 1
» Views: 483
non-paged supervisor code...
Forum: Help & Support
Last Post: sdo303
2026-02-20, 06:38 PM
» Replies: 8
» Views: 1,290
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,388
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 2,073
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 1,078
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 1,177
Hall of Fame - Include fo...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-28, 03:48 PM
» Replies: 0
» Views: 630
[SOLVED] Array layout bug...
Forum: Bug Reports
Last Post: Zoran
2025-10-25, 05:48 PM
» Replies: 2
» Views: 1,215
3DOS Commands?
Forum: Help & Support
Last Post: boriel
2025-10-06, 02:54 PM
» Replies: 3
» Views: 1,377

 
  First draft of DECLARE
Posted by: programandala.net - 2010-06-09, 03:51 PM - Forum: Documentation - Replies (3)

I've created the first draft of the DECLARE page.

Print this item

  <qbasic> in the docs
Posted by: programandala.net - 2010-06-09, 03:27 PM - Forum: Documentation - Replies (4)

Why the <qbasic> extension is used in the docs? The following code has been taken from the FUNCTION page:

Code:
<qbasic>FUNCTION Factorial(x AS Ulong) AS Ulong
    IF x < 2 THEN RETURN x: END IF
    RETURN Factorial(x - 1) * x
END FUNCTION</qbasic>

The extension highligths the code but also links the keywords to http://www.qbasicnews.com

Print this item

  New beta release 1.2.6r1603b
Posted by: boriel - 2010-06-06, 11:14 AM - Forum: Bug Reports - Replies (3)

This version just adds little improvements to the previous one:

  • Multiplication of bytes a little faster and smaller.
  • Compatibility for DO UNTIL <cond>... LOOP and DO WHILE <cond> ... LOOP as programandala asked.

Download at the Archive.

Note: If you want to be automagically you can register into the wiki and click on "Watch this", so each time the page is changed you will receive a notification (I think it would be a good idea). :roll:

Print this item

  Wiki Improvements
Posted by: britlion - 2010-06-04, 08:35 PM - Forum: Documentation - Replies (11)

All I can say is wow. I like!

I love the new navigation bars that are appearing. Much easier to find your way around with those as an option - I kept having to reload the start page.

Bravo! Thank you for this and all your efforts, Boriel.

Print this item

  BritLion's Putchars
Posted by: britlion - 2010-06-04, 06:35 PM - Forum: How-To & Tutorials - Replies (39)

LCD play with this.

The question is, this doesn't do attributes right now. How would you want that handled?

1> Assume it's at the end of the data block? (So if you use putchars for one character, it's the 9th byte. For a 2X2 block, it's the 65th, 66th, 67th and 68th...
2> A separate putAttribs function that works the same way
3> Leave it up to the user to do print at y,x, over 1, paper x, ink y;"<space>"

Something else?

I haven't tested mine against yours, I'm just assuming because of code efficiency, this is faster screen handling.
Edit: See below for test results

Edit: Fixed a bug - in BLPutCharNextThird add HL,DE and POP DE were backwards. Thanks to Compiuter for reporting this.

Edit: Shaved a few clock cycles off the graphics printing, and added a paint sub

Edit: Added a paintData sub

Code:
SUB paint (x as uByte,y as uByte, width as uByte, height as uByte, attribute as ubyte)
    asm
    ld      a,(IX+7)   ;ypos
    rrca
    rrca
    rrca               ; Multiply by 32
    ld      l,a        ; Pass to L
    and     3          ; Mask with 00000011
    add     a,88       ; 88 * 256 = 22528 - start of attributes. Change this if you are working with a buffer or somesuch.
    ld      h,a        ; Put it in the High Byte
    ld      a,l        ; We get y value *32
    and     224        ; Mask with 11100000
    ld      l,a        ; Put it in L
    ld      a,(IX+5)   ; xpos
    add     a,l        ; Add it to the Low byte
    ld      l,a        ; Put it back in L, and we're done. HL=Address.
    
    push HL            ; save address
    LD A, (IX+13)      ; attribute
    LD DE,32
    LD c,(IX+11)       ; height
    
    BLPaintHeightLoop:
    LD b,(IX+9)        ; width
    
    BLPaintWidthLoop:
    LD (HL),a          ; paint a character
    INC L              ; Move to the right (Note that we only would have to inc H if we are crossing from the right edge to the left, and we shouldn't be needing to do that)
    DJNZ BLPaintWidthLoop
    
    BLPaintWidthExitLoop:
    POP HL             ; recover our left edge
    DEC C
    JR Z, BLPaintHeightExitLoop
    
    ADD HL,DE          ; move 32 down
    PUSH HL            ; save it again
    JP BLPaintHeightLoop

    BLPaintHeightExitLoop:
    
    end asm
END SUB

SUB paintData (x as uByte,y as uByte, width as uByte, height as uByte, address as uInteger)
    asm
    ld      a,(IX+7)   ;ypos
    rrca
    rrca
    rrca               ; Multiply by 32
    ld      l,a        ; Pass to L
    and     3          ; Mask with 00000011
    add     a,88       ; 88 * 256 = 22528 - start of attributes. Change this if you are working with a buffer or somesuch.
    ld      h,a        ; Put it in the High Byte
    ld      a,l        ; We get y value *32
    and     224        ; Mask with 11100000
    ld      l,a        ; Put it in L
    ld      a,(IX+5)   ; xpos
    add     a,l        ; Add it to the Low byte
    ld      l,a        ; Put it back in L, and we're done. HL=Address.
    
    push HL            ; save address
    LD D, (IX+13)
    LD E, (IX+12)
    LD c,(IX+11)       ; height
    
    BLPaintDataHeightLoop:
    LD b,(IX+9)        ; width
    
    BLPaintDataWidthLoop:
    LD a,(DE)
    LD (HL),a          ; paint a character
    INC L              ; Move to the right (Note that we only would have to inc H if we are crossing from the right edge to the left, and we shouldn't be needing to do that)
    INC DE
    DJNZ BLPaintDataWidthLoop
                        
    
    BLPaintDataWidthExitLoop:
    POP HL             ; recover our left edge
    DEC C
    JR Z, BLPaintDataHeightExitLoop
    PUSH DE
    LD DE,32
    ADD HL,DE          ; move 32 down
    POP DE
    PUSH HL            ; save it again
    JP BLPaintDataHeightLoop

    BLPaintDataHeightExitLoop:
    
    end asm
END SUB  
    
    SUB putChars(x as uByte,y as uByte, width as uByte, height as uByte, dataAddress as uInteger)
    asm
    BLPutChar:
             LD      a,(IX+5)
             ;AND     31
             ld      l,a
             ld      a,(IX+7) ; Y value
             ld      d,a
             AND     24
             add     a,64 ; 256 byte "page" for screen - 256*64=16384. Change this if you are working with a screen address elsewhere, such as a buffer.
             ld      h,a
             ld      a,d
             AND     7
             rrca
             rrca
             rrca
             OR      l
             ld      l,a

    PUSH HL ; save our address

    LD E,(IX+12) ; data address
    LD D,(IX+13)
    LD B,(IX+9) ; width
    PUSH BC ; save our column count

    BLPutCharColumnLoop:

    LD B,(IX+11) ; height

    BLPutCharInColumnLoop:
  
    ; gets screen address in HL, and bytes address in DE. Copies the 8 bytes to the screen
    ld a,(DE) ; First Row
    LD (HL),a
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; second Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Third Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Fourth Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Fifth Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Sixth Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Seventh Row
    
    INC DE
    INC H
    ld a,(DE)
    LD (HL),a ; Eigth Row
    
    INC DE ; Move to next data item.
    
    DEC B
    JR Z,BLPutCharNextColumn
    ;The following code calculates the address of the next line down below current HL address.
    PUSH DE ; save DE
             ld   a,l  
             and  224  
             cp   224  
             jp   z,BLPutCharNextThird

    BLPutCharSameThird:
             ld   de,-1760
             ;and  a        
             add  hl,de      
             POP DE ; get our data point back.
             jp BLPutCharInColumnLoop

    BLPutCharNextThird:
             ld   de,32      
             ;and  a
             add  hl,de  
             POP DE ; get our data point back.
    JP BLPutCharInColumnLoop

    BLPutCharNextColumn:
    POP BC
    POP HL
    DEC B
    JP Z, BLPutCharsEnd

    INC L   ; Note this would normally be Increase HL - but block painting should never need to increase H, since that would wrap around.
    PUSH HL
    PUSH BC
    JP BLPutCharColumnLoop

BLPutCharsEnd:
    end asm

    END SUB

    goto start

    datapoint:
asm
defb 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32
defb 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64
defb 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96
defb 97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128
end asm

    start:
    cls
    putChars(10,10,3,3,@datapoint)
    paint(10,10,3,3,79)

Print this item

  New beta release 1.2.6r1603
Posted by: boriel - 2010-06-04, 12:37 AM - Forum: Bug Reports - Replies (3)

Hi

This beta release, 1.2.6r1603 adds the following:

  • #preprocessor directives into ASM BLOCKS are allowed again.
  • New command-line option, --enable-break that will make your program stoppable pressing BREAK (as in BASIC). This might be useful for debugging purposes, as the ROM error message will print the source line where break was pressed.
  • For loops scheme is now 10 T-states faster per loop.
  • PLOT, DRAW and CIRCLE are now 1% faster (better than nothing).
  • Array accesses are now 50-100% faster (thanks to Britlion for suggesting this).
  • Multi-line comments /' ... '/ now allowed (see Wiki), and also line comments after line break

If interested, please, download as always at <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb">http://www.boriel.com/files/zxb</a><!-- m -->
Intensive testing is needed.

Print this item

  Assembler shortcut
Posted by: britlion - 2010-06-03, 06:45 PM - Forum: Wishlist - Replies (1)

Not sure where else to put this - Not really a bug, per se, as an efficiency; I mentioned it elsewhere but I think it got lost.

With a sub that pokes memory based on labels:

eg:

Code:
SUB pokethis(data as uByte)
poke @label+1,data
return

label:
asm
LD A,00
end asm

Seems to produce assembler that does this:
Code:
ld hl, __LABEL__BLPutCharHeight
inc hl

Can the compiler not shortcut that to
Code:
ld hl, __LABEL__BLPutCharHeight+N ?
and work out at assembly time where that should be, thus producing shorter and faster code for what is, after all, a constant?

(or is there something clever in the optimizer that spots that sort of thing - load followed by incs or fixed adds?)

Print this item

  Unnecessary Push/Pop
Posted by: britlion - 2010-06-03, 06:41 PM - Forum: Bug Reports - Replies (3)

Not sure why the .asm ends up this way, but each time it pulls a parameter in a sub or function it seems to do this:

Code:
push hl
ld a, (ix+11)
pop hl

Why stack the HL register before loading the A register each time, and then unstack it immediately afterwards?

Print this item

  SyntaxError: invalid syntax in zxb.py (Resolved)
Posted by: ccowley - 2010-06-03, 01:13 PM - Forum: Help & Support - Replies (2)

I've just downloaded ZX BASIC from the zxbasic-latest-version.zip link to give it a try. I have Python 3.1.2 installed on a Windows 7 box.

Running zxb.py gives the following error:-

Code:
File "C:\Users\Chris\speccy\zxbasic\zxb.py", line 60
    print m # IGNORE # line directives as PASMO does not support them
          ^
SyntaxError: invalid syntax

I guess I must be doing something wrong, but what?

EDIT: Resolved. I uninstalled Python 3.1.2 and installed Python 2.6 instead. The zxbasic website says "you will need the python interpreter version 2.5 or higher installed on your system" - this should probably be amended to point out to non-python programmers (like me) that actually Python 3.x is no good as it's not backwardly compatible with v2.x.

Print this item

  Using PutcharLcd
Posted by: compiuter - 2010-06-02, 11:42 PM - Forum: How-To & Tutorials - Replies (8)

I was testing the Putchar Lcd´s routine and I think It´s very handly and work right for my games. Perhaps is not the fastest, but I´m happy with the facilities of modifying its code. Big Grin

Code:
'===========================
'= putchar lcd compiuter   =
'= version 1.100603 <-date =
'===========================
'#include <sinclair.bas>
'#include <memcopy.bas>
'#include <keys.bas>
'#include <print42.bas>
'#include <attr.bas>
'---
cls
border 5
'-------------------------------------
sub putcharLcd1x1(x as Uinteger,y as Uinteger,adr as Uinteger)
   dim scr as Uinteger
   dim a as Uinteger
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr)
   poke ubyte scr+256,peek(adr+1)
   poke ubyte scr+512,peek(adr+2)
   poke ubyte scr+768,peek(adr+3)
   poke ubyte scr+1024,peek(adr+4)
   poke ubyte scr+1280,peek(adr+5)
   poke ubyte scr+1536,peek(adr+6)
   poke ubyte scr+1792,peek(adr+7)
   poke ubyte 22528+x+(y<<5),peek (adr+8)
End sub
'-------------------------------------------
sub putcharLcd1x2(x as Uinteger,y as Uinteger,adr as Uinteger)
   dim scr as Uinteger
   dim a as Uinteger
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr)
   poke ubyte scr+256,peek(adr+1)
   poke ubyte scr+512,peek(adr+2)
   poke ubyte scr+768,peek(adr+3)
   poke ubyte scr+1024,peek(adr+4)
   poke ubyte scr+1280,peek(adr+5)
   poke ubyte scr+1536,peek(adr+6)
   poke ubyte scr+1792,peek(adr+7)
   poke ubyte 22528+x+(y<<5),peek (adr+8)
   x=x+1
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr+9)
   poke ubyte scr+256,peek(adr+10)
   poke ubyte scr+512,peek(adr+11)
   poke ubyte scr+768,peek(adr+12)
   poke ubyte scr+1024,peek(adr+13)
   poke ubyte scr+1280,peek(adr+14)
   poke ubyte scr+1536,peek(adr+15)
   poke ubyte scr+1792,peek(adr+16)
   poke ubyte 22528+x+(y<<5),peek (adr+17)
End sub
'-------------------------------------------
sub putcharLcd2x1(x as Uinteger,y as Uinteger,adr as Uinteger)
   dim scr as Uinteger
   dim a as Uinteger
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr)
   poke ubyte scr+256,peek(adr+1)
   poke ubyte scr+512,peek(adr+2)
   poke ubyte scr+768,peek(adr+3)
   poke ubyte scr+1024,peek(adr+4)
   poke ubyte scr+1280,peek(adr+5)
   poke ubyte scr+1536,peek(adr+6)
   poke ubyte scr+1792,peek(adr+7)
   poke ubyte 22528+x+(y<<5),peek (adr+8)
   y=y+1
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr+9)
   poke ubyte scr+256,peek(adr+10)
   poke ubyte scr+512,peek(adr+11)
   poke ubyte scr+768,peek(adr+12)
   poke ubyte scr+1024,peek(adr+13)
   poke ubyte scr+1280,peek(adr+14)
   poke ubyte scr+1536,peek(adr+15)
   poke ubyte scr+1792,peek(adr+16)
   poke ubyte 22528+x+(y<<5),peek (adr+17)
End sub
'-------------------------------------------
sub putcharLcd2x2(x as Uinteger,y as Uinteger,adr as Uinteger)
   dim scr as Uinteger
   dim a as Uinteger
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr)
   poke ubyte scr+256,peek(adr+1)
   poke ubyte scr+512,peek(adr+2)
   poke ubyte scr+768,peek(adr+3)
   poke ubyte scr+1024,peek(adr+4)
   poke ubyte scr+1280,peek(adr+5)
   poke ubyte scr+1536,peek(adr+6)
   poke ubyte scr+1792,peek(adr+7)
   poke ubyte 22528+x+(y<<5),peek (adr+8)
   x=x+1
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr+9)
   poke ubyte scr+256,peek(adr+10)
   poke ubyte scr+512,peek(adr+11)
   poke ubyte scr+768,peek(adr+12)
   poke ubyte scr+1024,peek(adr+13)
   poke ubyte scr+1280,peek(adr+14)
   poke ubyte scr+1536,peek(adr+15)
   poke ubyte scr+1792,peek(adr+16)
   poke ubyte 22528+x+(y<<5),peek (adr+17)
   x=x-1
   y=y+1
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr+18)
   poke ubyte scr+256,peek(adr+19)
   poke ubyte scr+512,peek(adr+20)
   poke ubyte scr+768,peek(adr+21)
   poke ubyte scr+1024,peek(adr+22)
   poke ubyte scr+1280,peek(adr+23)
   poke ubyte scr+1536,peek(adr+24)
   poke ubyte scr+1792,peek(adr+25)
   poke ubyte 22528+x+(y<<5),peek (adr+26)
   x=x+1
   a=peek(@linebuffer+y)
   scr=(a<<5)+x+16384
   poke ubyte scr,peek(adr+27)
   poke ubyte scr+256,peek(adr+28)
   poke ubyte scr+512,peek(adr+29)
   poke ubyte scr+768,peek(adr+30)
   poke ubyte scr+1024,peek(adr+31)
   poke ubyte scr+1280,peek(adr+32)
   poke ubyte scr+1536,peek(adr+33)
   poke ubyte scr+1792,peek(adr+34)
   poke ubyte 22528+x+(y<<5),peek (adr+35)
End sub
'---next will be probably putcharlcd1x3
'---
linebuffer:
asm
  defb 0,1,2,3,4,5,6,7,64,65,66,67,68,69,70,71,128,129,130,131,132,133,134,135
end asm
'--------------------------
start:
dim x,y as ubyte
dim adr as Uinteger

adr=@gfx1a
x=1
y=1
putcharLcd1x1(x,y,adr)

adr=@gfx1a
x=1
y=3
putcharLcd1x2(x,y,adr)

adr=@gfx1a
x=1
y=5
putcharLcd2x1(x,y,adr)

adr=@gfx1a
x=1
y=8
putcharLcd2x2(x,y,adr)
'---fin---
END
'----------------------------------------
gfx1a:
ASM
DEFB 0,8,8,8,8,8,8,0,00010001B
DEFB 0,60,4,4,60,32,60,0,00011001B
DEFB 0,60,4,4,60,4,60,0,00100001B
DEFB 0,36,36,36,60,4,4,0,00101001B
END ASM
'-----------------------------------------

Print this item