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: RichardFluof
» Forum threads: 1,074
» Forum posts: 6,434

Full Statistics

Online Users
There are currently 180 online users.
» 0 Member(s) | 178 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: 342
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,604
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: 336
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,888
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,815

 
  type problem (*solved*)
Posted by: slenkar - 02-14-2012, 03:23 AM - Forum: Bug Reports - Replies (10)

Code:
Function distance (x1 as Integer, y1 as Integer, x2 as Integer, y2 as Integer) as Integer
Dim x as Integer
x=Abs(x1-x2)
Dim y as Integer
y=Abs(y1-y2)
Return x+y
End Function

Dim bresx(0 to 300) as UByte
Dim bresy(0 to 300) as UByte

Function line(X1 as Integer,Y1 as Integer,X2 as Integer,Y2 as Integer) as Integer
'Draws a line of individual pixels from X1,Y1 to X2,Y2 at any angle

Dim dist as Integer
dist=distance(X1,Y1,X2,Y2)
dim bresiter as Integer
For bresiter=0 To dist
bresx(bresiter)=0
bresy(bresiter)=0
Next

Dim steep as Byte
steep=Abs(Y2-Y1) > Abs(X2-X1)
PRINT AT 1,1 ; PAPER 1 ; INK 0 ; "steep "+STR(steep)
    
If steep =1 Then
Dim Temp as Integer
steep=X1
X1=Y1
Y1=Temp
Temp=X2
X2=Y2
Y2=Temp
End If
    Dim DeltaX as Integer
    DeltaX=Abs(X2-X1)
    Dim DeltaY as Integer
    DeltaY=Abs(Y2-Y1)
    Dim IError as Integer
    IError=0
    Dim DeltaError as Integer
    DeltaError=DeltaY
    Dim x as Integer
    x=X1        'Start at X1,Y1
    Dim y as Integer
    y=Y1        
    Dim XStep as Integer
    Dim YStep as Integer
    If X1<X2 Then
    XStep=1
    Else
    XStep=-1
    end if
    If Y1<Y2 Then
    YStep=1
    Else
    YStep=-1    'Direction
    end if
    'If Steep Then Plot(Y,X) Else Plot(X,Y)        'Draw
    Dim iter as Integer=1
    
    While x<>X2
    'Print x+" <x "+X2+"<x2"
    'Print "xstep "+XStep
    'x=truncate(x,1)
        x=x+XStep        'Move in X
    'Print x+" <x after adding xstep "+X2+"<x2"
        
        IError=IError+DeltaError        'Add to counter
        If (IError Shl 1)>DeltaX then        'Would it overflow?
        y=y+YStep        'Move in Y
        IError=IError-DeltaX        'Overflow/wrap the counter
        End if
    '    x=truncate(x,1)
    '    y=truncate(y,1)
    '        Print x+" <x after truncating xstep "+X2+"<x2"
    
    If steep then
        bresx(iter)=y
    '    Print bresx[iter]+"<bresx  iter>"+iter
        bresy(iter)=x
    '    Print bresy[iter]+"<bresy  iter>"+iter

    Else
        bresx(iter)=x
    '    Print bresx[iter]+"<bresx  iter>"+iter

        bresy(iter)=y
    '        Print bresy[iter]+"<bresy  iter>"+iter

    End If
        iter=iter+1
        
    If iter>dist then
    Print  "bresenham over distance "+dist
    Return dist
    End If
    '    If Steep Then Plot(Y,X) Else Plot(X,Y)        'Draw
    Wend
    Return dist
End Function

line(0,0,10,5)
for x=0 to 6
    Plot bresx(x),bresy(x)
next

When I try to compile it says cant convert to string on line 16 but there are no strings being referred to on that line

EDIT- the problem was on line 107 so the compiler was confused

Print this item

  Astrology
Posted by: slenkar - 02-01-2012, 12:30 AM - Forum: Off-Topic - Replies (3)

hey, you can type in your birthday and get a description of your personality

LCD's birthday is on his website so I did his :
<!-- m --><a class="postlink" href="http://astro.cafeastrology.com/cgi-bin/astro/natal?member=&recalc=&name=LCD&sex=t&d1day=9&d1month=10&d1year=1971&d1hour=22&d1min=30&nohouses=true&citylist=Chorzow%2C+Poland&lang=en">http://astro.cafeastrology.com/cgi-bin/ ... nd&lang=en</a><!-- m -->

If LCD is reading this , does it match your personality?

Print this item

  Variables with random data in
Posted by: britlion - 01-29-2012, 11:39 PM - Forum: Bug Reports - Replies (2)

Not sure if it's a bug or design, but I seem to be finding random numbers in dimensioned arrays. I would have expected a DIM to set values to zero by default, I think?

Assuming that, and not looping through and setting them to zero is causing some very surprising values to pop up!

Print this item

  MegaLZ depacker
Posted by: britlion - 01-29-2012, 01:41 AM - Forum: How-To & Tutorials - Replies (14)

I was using MegaLZ, and I figured it worth listing how to make it a SUB.

Trivially easy, actually - it's provided as ASM source. There's a windows binary program to compress data. Just call this like a mem copy, with source (packed data) and destination (for unpacked data).

I've used it to pack down screen data, and just unpacked it to the screen - it's slow enough to be visible, so do it with attributes set to invisible, and the user won't notice.


Code:
SUB megaLZDepack (source as uInteger, dest as uInteger)
ASM

LD E,(IX+6)
LD D,(IX+7)

;Z80 depacker for megalz V4 packed files   (C) fyrex^mhm

; DESCRIPTION:
;
; Depacker is fully relocatable, not self-modifying,
;it's length is 110 bytes starting from DEC40.
;Register usage: AF,AF',BC,DE,HL. Must be CALL'ed, return is done by RET.
;Provide extra stack location for store 2 bytes (1 word). Depacker does not
;disable or enable interrupts, as well as could be interrupted at any time
;(no f*cking wicked stack usage :).

; USAGE:
;
; - put depacker anywhere you want,
; - put starting address of packed block in HL,
; - put location where you want data to be depacked in DE,
;   (much like LDIR command, but without BC)
; - make CALL to depacker (DEC40).
; - enjoy! ;)

; PRECAUTIONS:
;
; Be very careful if packed and depacked blocks coincide somewhere in memory.
;Here are some advices:
;
; 1. put packed block to the highest addresses possible.
;     Best if last byte of packed block has address #FFFF.
;
; 2. Leave some gap between ends of packed and depacked block.
;     For example, last byte of depacked block at #FF00,
;     last byte of packed block at #FFFF.
;
; 3. Place nonpackable data to the end of block.
;
; 4. Always check whether depacking occurs OK and neither corrupts depacked data
;     nor hangs computer.
;

;DEC40

        LD      A,80h
        EX      AF,AF'
MS:     LDI
M0:      LD      BC,2FFh
M1:      EX      AF,AF'
M1X:     ADD     A,A
        JR      NZ,M2
        LD      A,(HL)
        INC     HL
        RLA
M2:      RL      C
        JR      NC,M1X
        EX      AF,AF'
        DJNZ    X2
        LD      A,2
        SRA     C
        JR      C,N1
        INC     A
        INC     C
        JR      Z,N2
        LD      BC,33Fh
        JR      M1

X2:      DJNZ    X3
        SRL     C
        JR      C,MS
        INC     B
        JR      M1
X6:
        ADD     A,C
N2:
        LD      BC,4FFh
        JR      M1
N1:
        INC     C
        JR      NZ,M4
        EX      AF,AF'
        INC     B
N5:      RR      C
        JP     C, END_DEC40
        RL      B
        ADD     A,A
        JR      NZ,N6
        LD      A,(HL)
        INC     HL
        RLA
N6:      JR      NC,N5
        EX      AF,AF'
        ADD     A,B
        LD      B,6
        JR      M1
X3:
        DJNZ    X4
        LD      A,1
        JR      M3
X4:      DJNZ    X5
        INC     C
        JR      NZ,M4
        LD      BC,51Fh
        JR      M1
X5:
        DJNZ    X6
        LD      B,C
M4:      LD      C,(HL)
        INC     HL
M3:      DEC     B
        PUSH    HL
        LD      L,C
        LD      H,B
        ADD     HL,DE
        LD      C,A
        LD      B,0
        LDIR
        POP     HL
        JR      M0
        
        
END_DEC40:

END ASM
END SUB

Print this item

  another forum area for other platforms than zx-spectrum
Posted by: nitrofurano - 12-28-2011, 11:01 PM - Forum: Wishlist - Replies (41)

Since Boriel told us that this zxbasic compiler is planned to be flexible enough to target other platforms than only zx-spectrum, maybe another are of this forum could be created, where we could discuss information and knowledge which could help on this, since i'm seeing that more people could be interested on helping

For example, i were about trying to create stuff for msx2+ (for example, using laced screen12 or screen7) using this zxbasic-compiler, but i'm concerned on how it could create incompatible binaries (like using rom calls or system variable accesses from zx-spectrum ), and targeting 'bloadable' binaries, or .rom files

(for example as well, would be interesting seeing stuff made for msxdev contest made with this Boriel's zxbasic-compiler)

I readed somewhere that Boriel mentioned other z80 machines as well, like Amstrad - btw, the idea is about this, having a kind of shared brainstorm here about all 8bit hardware manufactured (also like zx81, Mattel Aquarius, sharp mz700, nec pc6001, etc.), which components each one has and how are they used, how they deal with ansi-basic language, etc. - maybe we should start something on the wiki pages as well?

I think information like this, and accessible as well, can help a lot, not only the multiplatform cross-development target of this compiler, as can help as well retro developers and teams (like those wonderful Mojon Twins team) on developing on all these other hardware as well - this would be wonderful!

what do you all think about? and who can help, and on what?

Print this item

  "Quest for Witchcraft"
Posted by: LCD - 12-24-2011, 01:06 AM - Forum: Gallery - Replies (17)

My "Jewel Quest" based game called "Quest for Witchcraft" for the Spectrum is finished:
[Image: QuestForWitchcraft.gif]
At present time it is exclusively written for the "Scene+" disczine, but will be available later (late next year) also for free.
I just waiting for the Beeper Music from Mr Beep now.
More infos on my website, and I will send the finished version soon to Boriel too.

Print this item

  SamCoupé palette support
Posted by: nitrofurano - 12-21-2011, 03:26 AM - Forum: Library - Replies (3)

Some people here may know that zx-spectrum stuff can run on sam coupé machines, and these stuff can write on its palette as well.

This is based on the library i added to support ULAplus, and did the enough changes for the SamCoupé - i didn't test it yet.

There are differences - while ULAplus has 64 palette colours from 256, SamCoupé has 16 from 128, and arranged in a different way. And anyway, SamCoupé palette seems to be simpler to use, since there are no need for tricky subroutines like "ulaplusattr(ikv as ubyte,pav as ubyte)"

Besides the ULAplus version, i don't know or i have no way to get the palette values back, or test if the machine uses SamCoupé palette

I didn't test this code yet - SimCoupé seems to be a good emulator for testing it:

library/samcoupepalette.bas

Code:
dim tmpv as uinteger

sub samcoupepalette(clv as ubyte, vlv as ubyte):
  out (clv*256)bor 248,vlv:pause 1
  end sub

function samcoupehexcolour(hxcv as uinteger):
  tmpv=(hxcv band 4)/4
  tmpv=tmpv bor ((hxcv band 64)/16)
  tmpv=tmpv bor ((hxcv band 8)*2)
  tmpv=tmpv bor ((hxcv band 128)/2)
  tmpv=tmpv bor ((hxcv band 32)/4)
  hxcv=int(hxcv/256)
  tmpv=tmpv bor ((hxcv band 64)/16)
  tmpv=tmpv bor ((hxcv band 8)*2)
  return tmpv
  end function

the information on the code above is based on the reply i got from Velesoft at <!-- m --><a class="postlink" href="http://www.worldofspectrum.org/forums/showthread.php?p=583022#post583022">http://www.worldofspectrum.org/forums/s ... post583022</a><!-- m -->

Print this item

  Used to compile? (*solved*)
Posted by: britlion - 12-08-2011, 02:08 AM - Forum: Bug Reports - Replies (7)

I think this used to work. Now it just gets a blank screen?

Based on HRPrintFast - as attached in the forum.

zxb --version
zxb 1.2.8-s758

<!-- m --><a class="postlink" href="http://dl.dropbox.com/u/4903664/HRPrintFast.zip">http://dl.dropbox.com/u/4903664/HRPrintFast.zip</a><!-- m -->

(I can't seem to attach this file to the forum either: Could not upload attachment to ./files/292_dbf5619d9a32ca38360a971b2a2970cd.)

Print this item

  scroll.bas
Posted by: britlion - 12-07-2011, 10:27 PM - Forum: Bug Reports - Replies (9)

Was thinking of doing some scroll routines. I see there are some useful ones in scroll.bas in the library.

However, there appears to be a left, right and another left in there - no up and down!

sub fastcall ScrollRight
sub fastcall ScrollLeft
sub fastcall ScrollLeft

two also begin a bit strangely - loading the byte at (screenaddress) twice?

Print this item

  Window Scroll Up
Posted by: britlion - 12-07-2011, 07:20 PM - Forum: How-To & Tutorials - No Replies

For what it's worth, I added a window up scroll routine to the library. Allows text areas to be scrolled up as they fill up, without messing up other areas of the screen.

<!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:WindowScrollUp">http://www.boriel.com/wiki/en/index.php ... owScrollUp</a><!-- m -->

Print this item