The following warnings occurred:
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval
Warning [2] Undefined array key "attachments" - Line: 20 - File: portal.php(680) : eval()'d code PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/portal.php(680) : eval()'d code 20 errorHandler->error_callback
/portal.php 680 eval




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 135 online users.
» 0 Member(s) | 134 Guest(s)
Bing

Latest Threads
New video Couse / Nuevo c...
Forum: News
Last Post: Duefectu
2026-04-29, 11:02 PM
» Replies: 0
» Views: 212
location of heap manageme...
Forum: Help & Support
Last Post: boriel
2026-03-07, 12:13 AM
» Replies: 1
» Views: 485
non-paged supervisor code...
Forum: Help & Support
Last Post: sdo303
2026-02-20, 06:38 PM
» Replies: 8
» Views: 1,297
How to open fuse as an ex...
Forum: How-To & Tutorials
Last Post: Duefectu
2026-02-09, 01:52 PM
» Replies: 3
» Views: 1,389
Old zxbasic game errors
Forum: Help & Support
Last Post: boriel
2025-11-09, 11:52 AM
» Replies: 7
» Views: 2,076
Error: Undefined GLOBAL l...
Forum: Help & Support
Last Post: ardentcrest
2025-11-04, 05:46 PM
» Replies: 3
» Views: 1,080
A Fast(er) Plot Routine f...
Forum: How-To & Tutorials
Last Post: tubz74
2025-10-30, 03:16 PM
» Replies: 2
» Views: 1,179
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,217
3DOS Commands?
Forum: Help & Support
Last Post: boriel
2025-10-06, 02:54 PM
» Replies: 3
» Views: 1,380

 
  Line of sight
Posted by: slenkar - 2012-02-15, 07:56 PM - Forum: How-To & Tutorials - Replies (28)

To see if 2 game characters can see each other you need 2 functions

distance:

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 Sqr((x^2)+(y^2)) End Function

line:
Code:
Function line(X1 as Integer,Y1 as Integer,X2 as Integer,Y2 as Integer) as Integer 'creates a line of individual co-ords 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 Integer if Abs(Y2-Y1) > Abs(X2-X1) then steep=1 else steep=0 end if PRINT AT 1,0 ; PAPER 1 ; INK 0 ; "steep "+STR(steep) If steep =1 Then Dim Temp as Integer Temp=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 Dim iter as Integer iter=1 While x<>X2 x=x+XStep 'Move in X 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 If steep then bresx(iter)=y bresy(iter)=x Else bresx(iter)=x bresy(iter)=y End If iter=iter+1 If iter>dist then 'Print at 3,0;PAPER 1;INK 0;"bresenham over distance "+STR(dist) Return dist End If Wend Return dist End Function

create 2 arrays to hold the x and y coordinates of the line
Code:
Dim bresx(350) as Integer Dim bresy(350) as Integer

The size of the arrays should be the distance of the longest line you intend to create
a line going across the screen of the speccy is about 322 in length

You have 2 characters on a playing field that has x and y coordinates

you call the line function:
one character is at 1,1
the other is at 100,95
Code:
Dim dist as Integer dist=line(1,1,100,95)

then finally you go through the co-ordinates on the line to check if anything is in the way, like walls or other characters
Code:
Dim can_see:UByte can_see=1 for x=0 to dist if wall_in_way(bresx(x),bresy(x)) then can_see=0 end if next if can_see =1 then 'yes they can see each other end if if can_see =0 then 'no they can not see each other end if

Print this item

  Float to Int?
Posted by: slenkar - 2012-02-14, 03:37 PM - Forum: How-To & Tutorials - Replies (1)

how do you convert a float to an int?

Print this item

  Isqrt.bas (*solved*)
Posted by: slenkar - 2012-02-14, 03:30 PM - Forum: Bug Reports - Replies (4)

When I try to use Isqrt.bas it says:

ISqrt.bas:125: Error: illegal preprocessor character '$'

Print this item

  191 plots causes crash
Posted by: slenkar - 2012-02-14, 02:58 PM - Forum: Help & Support - Replies (2)

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 255) as Integer Dim bresy(0 to 191) as Integer 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 Integer if Abs(Y2-Y1) > Abs(X2-X1) then steep=1 else steep=0 end if PRINT AT 1,0 ; PAPER 1 ; INK 0 ; "steep "+STR(steep) If steep =1 Then Dim Temp as Integer Temp=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 Dim iter as Integer iter=1 While x<>X2 x=x+XStep 'Move in X 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 If steep then bresx(iter)=y bresy(iter)=x Else bresx(iter)=x bresy(iter)=y End If iter=iter+1 If iter>dist then Print at 3,0;PAPER 1;INK 0;"bresenham over distance "+STR(dist) Return dist End If Wend Return dist End Function Dim dist as Integer dist=line(1,1,100,95)-1 PRINT AT 0,0 ; PAPER 1 ; INK 0 ; "dist "+STR(dist) for x=0 to dist Plot bresx(x),bresy(x) next 'PRINT AT 2,0 ; PAPER 1 ; INK 0 ; "bresx "+STR(bresx(108)) 'PRINT AT 3,0 ; PAPER 1 ; INK 0 ; "bresx "+STR(bresx(57)) 'PRINT AT 4,0 ; PAPER 1 ; INK 0 ; "bresx "+STR(bresx(18)) 'PRINT AT 5,0 ; PAPER 1 ; INK 0 ; "bresy "+STR(bresy(108)) 'PRINT AT 6,0 ; PAPER 1 ; INK 0 ; "bresy "+STR(bresy(59)) 'PRINT AT 7,0 ; PAPER 1 ; INK 0 ; "bresy "+STR(bresy(1)) 'main loop 100 LET j$ = INKEY$ GOTO 100

Im implementing a bresenham thingy for line of sight calculations,
whenever the length of the line exceeds 191 the screen gets corrupted,
191 just happens to be the height of the screen, but I dont see the relation.

Print this item

  type problem (*solved*)
Posted by: slenkar - 2012-02-14, 04: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 - 2012-02-01, 01: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 - 2012-01-30, 12:39 AM - 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 - 2012-01-29, 02: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 - 2011-12-29, 12:01 AM - 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 - 2011-12-24, 02: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