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

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

 
  Compiuter PlotChat
Posted by: compiuter - 06-19-2010, 08:12 PM - Forum: How-To & Tutorials - Replies (18)

I am working in this routine pixel-precise.
It is ripped from microhobby and wos forum.
Modified by me. I need help to complete the paint attributes method, because in asm my routine works fine, baut when I passed t sub It fails.
Here is the code.
Modified 20-June-2010 included colour ripped by wos
Modified 21-June-2010 included attributes in the same sub.
Now are two independent subs methods:
1.-PlotChar(file,column,CharAdr)
PlotCharPaint(file,column,atribute)
2.- PlotChat(file,column,CharAdr,atrib)
Probably, this is the last update for this routine.

Modified 2010-07-09 including fastcall and all asm routines embebed. The on ly problem is because the rets in atributes process make me save three bytes in printer buffer. Also I can not use Ubyte in fastcall because I do not understand how it works.

Code:
'==========================
'=plotchat=v3.100709=======
'==========================
'ripped from microhobby and
'wos forum
'thx to britlion lcd boriel
'--------------------------
border 6
cls
'demo of PlotChar
Dim YoF,YoC As Ubyte
YoF=50:YoC=70
YoCharAdr=@manwen
PlotChar(100,200,YoCharAdr)
PlotCharPaint(100,200,01101001b)
'---
dim w as ubyte
w=0
'---
    PlotChat((256*32)+512,@manwen,01101001b)
    do
     'char paper7 = 00111010b
     PlotChat(w,@manwen,00110010b)
       asm
         halt
          ;slow movement
       end asm
     PlotChat(w,@manwen,00111010b)
     w=w+1
'      YoF=YoF+1
    loop until w>255
end
'=fin======================
FUNCTION FASTCALL PlotChat(paramHL AS Uinteger,paramDE AS Uinteger,paramBC AS Uinteger)
asm
;hl-atr de-coord bc-graf
ld b,h ;pilla atr,0
ld c,l ;BFActual(0)
pop hl ;recup ret
pop de ;pilla p2-coord
ex (sp),hl ;pilla p3-graf
;---
;bc-atr de-coord bc-graf
;--------------------------
;### primera parte
;--------------------------
;para:
; ld hl,16384
; ld (hl),a
; jr para  
;el atributo viene en L
   ;en de debe estar manwen
   ;en bc estan las coords b-row c-col
   ;descartamos a=pareado del atributo
;---
   ;enterramos las coords
ld a,c
ld (23500),a
ld a,b
ld (23501),a
   ;enterramos el atrib para luego
ld a,l
ld (23502),a
;---
;comment halt for thrust the movement
  halt
prixoratr:
   ;--------------------
   ;entrada e=dirmemLB 22
   ;        d=dirmemHB 256*X
   ;        H=pareja del atributo
   ;        L=atributo 33
   ;        b=coord row   256*X
   ;        c=coord colum 11
   ;        a=se queda a cero
   ;          1er byte de la figura?
   ;--------------------
;   ld e,(IX+7) ;file
;   ld d,(IX+5) ;colum
;   ld l,(IX+8) ;lowbyte  charadr
;   ld h,(IX+9) ;highbyte charadr
    ex de,hl
    ld d,b
    ld e,c
   ld b,8
  bucbyt2:
   ld a,(hl)
   ;byte del carac
   push bc
   ;guar cont bytes
   ld b,8
   bucbit2:
   push bc
   ;guar cont bits
   rla
   ;desplaza un bit
   jr nc,noplot2
   ;si era 0 no pinta
   ld b,d
   ;b=y  ;aki va d
   ld c,e
   ;c=x  ;aki va e
   push de
   ;guar regs
   push hl
   push af
   ;aki jamas un halt enlentece mucho
   call co2 ;hace plot c,b
   ;pero plotw de mh63
   pop af    
   ;recup byte car
   pop hl    
   ;recup dir del byte
   pop de    
   ;recup coords
  noplot2:
   inc e
   ;inc x
   pop bc    
   ;recup cont bits
   djnz bucbit2
   ;prox bit
   inc d
   ;dec y
   pop bc
   ;recup cont bytes
   inc hl
   ;dir del byte
   ;dec hl ;dir del byte
   ld a,248
   ;a=-8
   add a,e
   ;resta 8 a x
   ld e,a
   djnz bucbyt2
   ;prox byte
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ret
   ;============
   ;MH63PLOTW
   ;============
   ; screen  010VVsss  vvvHHHHH
   ; coords  VVxxxvvv  HHHHHsss
   ; objeto  010VVvvv  xxxHHHHH  sss
   ; xxx son despreciados
   ;------------------------
  co2:
   ld b,d
   ld c,e
   LD H,40h ;0100-0000 = 16384
   LD A,B ;b=x=fila VVxxxvvv
   AND 7 ;0000-0vvv
   ADD A,H ;0100-0vvv
   LD H,A ;aseguramos H
   ;intermedio
   SRL B ;0VVxxxvv
   SRL B ;00VVxxxv
   SRL B ;000VVxxx
   LD A,B ;000VVxxx
   AND 24  ;000VV000
   ADD A,H ;010VVvvv
   LD H,A ;desprecias xxx de la vertical
   ;fin del primer trabajo B
   ;---
   LD A,B ;000VVxxx
   AND 7  ;00000xxx
   RRCA   ;x00000xx
   RRCA   ;xx00000x
   RRCA   ;xxx00000
   LD L,A ;
   LD A,C ;c=y=colum HHHHHsss
   AND 7  ;00000sss
   LD B,A ;B=00000sss ;el bit
   ;---
   SRL C  ;0HHHHHss
   SRL C  ;00HHHHHs
   SRL C  ;000HHHHH
   LD A,C  ;000HHHHH
   ADD A,L ;xxxHHHHH
   LD L,A            ;la horizontal
   ;---inicio bucle inversor
   INC B      ;B=00000sss + 1
   XOR A      ;A=00000000
   SCF        ;F=xxxx-xxx1
  c12:
   RRA      ;A=1000-0000
   DJNZ c12
   ; limpiamos A = 0000-0000
   ; buscamos un pixel
   ; el SFC mete un 1 al principio
   ; y RRA corre B veces hacia der ese 1
   XOR (HL)   ;orea A con dfbyte
   LD (HL),A ;para no borrar ant
   XOR (HL) ;en negro pone punto blanco
   ; OR (HL) ;hace over sobre punto negro
   ;RET
;-----------------
priatr2:
;Ripped from Wos-Turkwel
; ld c,(IX+7)
; ld b,(IX+5)
; ld a,(IX+11)
;desentierro coords
push hl
ld hl,23500
ld c,(hl)
inc hl
ld b,(hl)
   ;desenterramos el atrib
inc hl
ld a,(hl)
pop hl
    ;use alongside the print_char routine to set Attribute values automatically.......
    ;on entry BC uses exactly the same Y\X values as the print_char routine and A holds the Atrribute Value to be used.
    ;
    ;NB If you don't want to use A this way then set up something like ld a,(nnnn) at the start of the print_attribute routine
    ;instead and that way you can use your own "Sytem Variable" for printing each time
    ;
    ;suggested use:    ld a,"A"
    ;        ld bc,184*256+249
    ;        push bc
    ;        call print_char
    ;        pop bc
    ;        ld a,128+64+5
    ;        call print_attribute
    ;        ret
    ;
    ;alternatively you can integrate this into the print_char routine by looking after BC and A...it doesn't matter which way
    ;round you use it...char\attributes or attributes\char
print_attributew:
    ld d,0
    ld e,a
    ;transfer Attribute Byte to e for easier use
    ld a,b
    cp 192
    ret nc
    ;check Y position and exit if off bottom of screen
    push bc
    ;save off Y and X values for later
    and 248
    ld h,22
    ld l,a
    add hl,hl
    add hl,hl
    srl c
    srl c
    srl c
    ld b,d
    add hl,bc
    ;calculate the correct Attribute Address for the Y\X values
    ld (hl),e
    ;set the Attribute - this is ALWAYS set no matter what the valid Y\X values used
    pop bc
    ;get the Y and X values back into BC
    call print_attribute2
    ;call the subroutine to see if an adjacent Horizontal Attribute needs to be set
    ;
    ld a,b
    cp 184
    ret nc
    ;check to see if we are at Vertical character 23 - if so then no need to set adjacent Vertical Attribute & Exit routine
    and 7
    ret z
    ;and don't set the adjacent Vertical Attribute if there's no need to & Exit routine
    ld a,l
    add a,32
    ld l,a
    ld a,d
    adc a,h
    ld h,a
    ld (hl),e
    ;set the Attribute address to the line below  - and set the adjacent Vertical Attribute
    ;
    ;drop through now into adjacent Horizontal Attribute subroutine - all RETs will now Exit the routine completely
    ;
print_attribute2w:
    ld a,c
    cp 248
    ret nc
    ;check to see if we are at Horizontal character 31 - if so then no need to set adjacent Horizontal Attribute
    and 7
    ret z
    ;and don't set the adjacent Horizontal Attribute if there's no need to
    inc l
    ld (hl),e
    dec l
    ;increment the Attribute address - set the adjacent horizontal Attribute - then set the Attribute Address back
    ret
end asm
end function
'fin del fastcall plotchat
'==========================
FUNCTION FASTCALL PlotChar(ROWparamHL AS Uinteger,COLparamDE AS Uinteger,ADRparamBC AS Uinteger)
asm
  ;hl-atr de-coord bc-graf
  ld b,h ;pilla atr,0
  ld c,l ;BFActual(0)
  pop hl ;recup retorno
  pop de ;pilla p2-coord
  ex (sp),hl ;pilla p3-graf
  ;---
  ;bc-atr de-coord bc-graf
  ;--------------------------
  ;### primera parte
  ;--------------------------
  ;---entrada----------------
  ;ROWparamHL bring C  uinteger
  ;COLparamDE bring E  uinteger
  ;ADRparamBC bring hl uinteger
  ;--------------------------
prixor:
   ;--------------------
   ;entrada e=columnaDF
   ;        d=filaDF
   ;        hl=dirmem figura
   ;        a=primer byte de figura
   ;
   ;--------------------
   ld d,c ;row
   ;ld e,e ;col
   ;change order row x col
   ;hl ya viene predicho
   ;ld l,(IX+8) ;lowbyte  charadr
   ;ld h,(IX+9) ;highbyte charadr
   ld b,8
  bucbyt:
   ld a,(hl)
   ;byte del carac
   push bc
   ;guar cont bytes
   ld b,8
   bucbit:
   push bc
   ;guar cont bits
   rla
   ;desplaza un bit
   jr nc,noplot
   ;si era 0 no pinta
   ld b,d
   ;b=y  ;aki va d
   ld c,e
   ;c=x  ;aki va e
   push de
   ;guar regs
   push hl
   push af
   ;aki jamas un halt enlentece mucho
   call co ;hace plot c,b
   ;pero plotw de mh63
   pop af    
   ;recup byte car
   pop hl    
   ;recup dir del byte
   pop de    
   ;recup coords
  noplot:
   inc e
   ;inc x
   pop bc    
   ;recup cont bits
   djnz bucbit
   ;prox bit
   inc d
   ;dec y
   pop bc
   ;recup cont bytes
   inc hl
   ;dir del byte
   ;dec hl ;dir del byte
   ld a,248
   ;a=-8
   add a,e
   ;resta 8 a x
   ld e,a
   djnz bucbyt
   ;prox byte
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ret
   ;============
   ;MH63PLOTW
   ;============
   ; screen  010VVsss  vvvHHHHH
   ; coords  VVxxxvvv  HHHHHsss
   ; objeto  010VVvvv  xxxHHHHH  sss
   ; xxx son despreciados
   ;------------------------
  co:
   ld b,d
   ld c,e
   LD H,40h ;0100-0000 = 16384
   LD A,B ;b=x=fila VVxxxvvv
   AND 7 ;0000-0vvv
   ADD A,H ;0100-0vvv
   LD H,A ;aseguramos H
   ;intermedio
   SRL B ;0VVxxxvv
   SRL B ;00VVxxxv
   SRL B ;000VVxxx
   LD A,B ;000VVxxx
   AND 24  ;000VV000
   ADD A,H ;010VVvvv
   LD H,A ;desprecias xxx de la vertical
   ;fin del primer trabajo B
   ;---
   LD A,B ;000VVxxx
   AND 7  ;00000xxx
   RRCA   ;x00000xx
   RRCA   ;xx00000x
   RRCA   ;xxx00000
   LD L,A ;
   LD A,C ;c=y=colum HHHHHsss
   AND 7  ;00000sss
   LD B,A ;B=00000sss ;el bit
   ;---
   SRL C  ;0HHHHHss
   SRL C  ;00HHHHHs
   SRL C  ;000HHHHH
   LD A,C  ;000HHHHH
   ADD A,L ;xxxHHHHH
   LD L,A            ;la horizontal
   ;---inicio bucle inversor
   INC B      ;B=00000sss + 1
   XOR A      ;A=00000000
   SCF        ;F=xxxx-xxx1
  c1:
   RRA      ;A=1000-0000
   DJNZ c1
   ; limpiamos A = 0000-0000
   ; buscamos un pixel
   ; el SFC mete un 1 al principio
   ; y RRA corre B veces hacia der ese 1
   XOR (HL)   ;orea A con dfbyte
   LD (HL),A ;para no borrar ant
   XOR (HL) ;en negro pone punto blanco
   ; OR (HL) ;hace over sobre punto negro
  ret
end asm
end function
'fin del fastcall plotchar
'==========================
sub PlotCharViaSub(row as ubyte,colum as ubyte, charadr as uinteger)
asm
   halt
  prixor3:
   ;--------------------
   ;entrada e=columnaDF
   ;        d=filaDF
   ;        hl=dirmem figura
   ;        a=primer byte de figura
   ;
   ;--------------------
   ld e,(IX+7) ;row
   ld d,(IX+5) ;colum
   ld l,(IX+8) ;lowbyte  charadr
   ld h,(IX+9) ;highbyte charadr
   ld b,8
  bucbyt3:
   ld a,(hl)
   ;byte del carac
   push bc
   ;guar cont bytes
   ld b,8
  bucbit3:
   push bc
   ;guar cont bits
   rla
   ;desplaza un bit
   jr nc,noplot3
   ;si era 0 no pinta
   ld b,d
   ;b=y  ;aki va d
   ld c,e
   ;c=x  ;aki va e
   push de
   ;guar regs
   push hl
   push af
   ;aki jamas un halt enlentece mucho
   call co ;hace plot c,b
   ;pero plotw de mh63
   pop af    
   ;recup byte car
   pop hl    
   ;recup dir del byte
   pop de    
   ;recup coords
  noplot3:
   inc e
   ;inc x
   pop bc    
   ;recup cont bits
   djnz bucbit3
   ;prox bit
   inc d
   ;dec y
   pop bc
   ;recup cont bytes
   inc hl
   ;dir del byte
   ;dec hl ;dir del byte
   ld a,248
   ;a=-8
   add a,e
   ;resta 8 a x
   ld e,a
   djnz bucbyt3
   ;prox byte
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ;dec d
   ret
   ;============
   ;MH63PLOTW
   ;============
   ; screen  010VVsss  vvvHHHHH
   ; coords  VVxxxvvv  HHHHHsss
   ; objeto  010VVvvv  xxxHHHHH  sss
   ; xxx son despreciados
   ;------------------------
  co3:
   ld b,d
   ld c,e
   LD H,40h ;0100-0000 = 16384
   LD A,B ;b=x=fila VVxxxvvv
   AND 7 ;0000-0vvv
   ADD A,H ;0100-0vvv
   LD H,A ;aseguramos H
   ;intermedio
   SRL B ;0VVxxxvv
   SRL B ;00VVxxxv
   SRL B ;000VVxxx
   LD A,B ;000VVxxx
   AND 24  ;000VV000
   ADD A,H ;010VVvvv
   LD H,A ;desprecias xxx de la vertical
   ;fin del primer trabajo B
   ;---
   LD A,B ;000VVxxx
   AND 7  ;00000xxx
   RRCA   ;x00000xx
   RRCA   ;xx00000x
   RRCA   ;xxx00000
   LD L,A ;
   LD A,C ;c=y=colum HHHHHsss
   AND 7  ;00000sss
   LD B,A ;B=00000sss ;el bit
   ;---
   SRL C  ;0HHHHHss
   SRL C  ;00HHHHHs
   SRL C  ;000HHHHH
   LD A,C  ;000HHHHH
   ADD A,L ;xxxHHHHH
   LD L,A            ;la horizontal
   ;---inicio bucle inversor
   INC B      ;B=00000sss + 1
   XOR A      ;A=00000000
   SCF        ;F=xxxx-xxx1
  c13:
   RRA      ;A=1000-0000
   DJNZ c13
   ; limpiamos A = 0000-0000
   ; buscamos un pixel
   ; el SFC mete un 1 al principio
   ; y RRA corre B veces hacia der ese 1
   XOR (HL)   ;orea A con dfbyte
   LD (HL),A ;para no borrar ant
   XOR (HL) ;en negro pone punto blanco
   ; OR (HL) ;hace over sobre punto negro
   RET
end asm
end sub
'==========================
FUNCTION FASTCALL PlotCharPaint(ROWparamHL AS Uinteger,COLparamDE AS Uinteger,ATRparamBC AS Uinteger)
asm
  ;hl-atr de-coord bc-graf
  ld b,h ;pilla atr,0
  ld c,l ;BFActual(0)
  pop hl ;recup retorno
  pop de ;pilla p2-coord
  ex (sp),hl ;pilla p3-graf
  ;---
  ;bc-atr de-coord bc-graf
  ;--------------------------
  ;### primera parte
  ;--------------------------
  ;---entrada----------------
  ;ROWparamHL bring C  uinteger
  ;COLparamDE bring E  uinteger
  ;ATRparamBC bring hl uinteger
  ;--------------------------
priatr:
;Ripped from Wos-Turkwel
  ld b,c
  ld c,e
  ld a,l ;atr ok
    ;use alongside the print_char routine to set Attribute values automatically.......
    ;on entry BC uses exactly the same Y\X values as the print_char routine and A holds the Atrribute Value to be used.
    ;
    ;NB If you don't want to use A this way then set up something like ld a,(nnnn) at the start of the print_attribute routine
    ;instead and that way you can use your own "Sytem Variable" for printing each time
    ;
    ;suggested use:    ld a,"A"
    ;        ld bc,184*256+249
    ;        push bc
    ;        call print_char
    ;        pop bc
    ;        ld a,128+64+5
    ;        call print_attribute
    ;        ret
    ;
    ;alternatively you can integrate this into the print_char routine by looking after BC and A...it doesn't matter which way
    ;round you use it...char\attributes or attributes\char
print_attribute:
    ld d,0
    ld e,a
    ;transfer Attribute Byte to e for easier use
    ld a,b
    cp 192
    ret nc
    ;check Y position and exit if off bottom of screen
    push bc
    ;save off Y and X values for later
    and 248
    ld h,22
    ld l,a
    add hl,hl
    add hl,hl
    srl c
    srl c
    srl c
    ld b,d
    add hl,bc
    ;calculate the correct Attribute Address for the Y\X values
    ld (hl),e
    ;set the Attribute - this is ALWAYS set no matter what the valid Y\X values used
    pop bc
    ;get the Y and X values back into BC
    call print_attribute2
    ;call the subroutine to see if an adjacent Horizontal Attribute needs to be set
    ;
    ld a,b
    cp 184
    ret nc
    ;check to see if we are at Vertical character 23 - if so then no need to set adjacent Vertical Attribute & Exit routine
    and 7
    ret z
    ;and don't set the adjacent Vertical Attribute if there's no need to & Exit routine
    ld a,l
    add a,32
    ld l,a
    ld a,d
    adc a,h
    ld h,a
    ld (hl),e
    ;set the Attribute address to the line below  - and set the adjacent Vertical Attribute
    ;
    ;drop through now into adjacent Horizontal Attribute subroutine - all RETs will now Exit the routine completely
    ;
print_attribute2:
    ld a,c
    cp 248
    ret nc
    ;check to see if we are at Horizontal character 31 - if so then no need to set adjacent Horizontal Attribute
    and 7
    ret z
    ;and don't set the adjacent Horizontal Attribute if there's no need to
    inc l
    ld (hl),e
    dec l
    ;increment the Attribute address - set the adjacent horizontal Attribute - then set the Attribute Address back
    ret
end asm
end function
'==========================
'-----------------
'------
manwen:
asm
db 00011000b
db 00001010b
db 01111110b
db 01011000b
db 00011000b
db 00111100b
db 00100100b
db 00000000b
end asm
'---
'==========================

Print this item

  how to #include files with relative path to the current one?
Posted by: programandala.net - 06-19-2010, 12:25 PM - Forum: Help & Support - Replies (4)

#include <file> includes from the library; in order to include from the directory of the including file, the main program, i tried #include <./file> but it doesn't work. Even #include <~/path_to_the_project/file> doesn't work.

The only solution I've found is: #include </home/user/path_to_the_project/file>, that is, including the whole path from the file system root.

Is there any way to configure the including directories? It would be great to include files with relative path from the current directory if they exist, and from the library if they don't exist.

Print this item

  Suggestion about the functions and the brackets
Posted by: programandala.net - 06-18-2010, 04:52 PM - Forum: Documentation - Replies (3)

I suggest to always use brackets with functions, both in the Syntax and Examples sections, and everywhere in the docs.

I suggest to include a note in the language reference page in order to explain that brackets are optional in functions for the sake of compatibility with Sinclair BASIC (and maybe FreeBASIC in some cases). But that's all.

I think the code is much more clear with brackets; they help to avoid bugs too. And it's the standard beside a good practice, isn't it? On the other hand, it's good to have a clear convention to write the docs.

Print this item

  Suggestion for the Syntax section
Posted by: programandala.net - 06-18-2010, 04:42 PM - Forum: Documentation - Replies (20)

Hi all,

I've been thinking how to simplify and homogenize the docs; and also how to make them easier to create and mantain.

I'm preparing a list of detailed suggestions for your consideration, but the first one is ready:

I suggest for the Syntax section:

  • to use <freebasic></freebasic>. I think it's easier to write and to read, and it looks nicer and more clear. The current combination of bold and italic is not comfortable to edit (besides, I think their Mediawiki notation is unhandy and hard to read).
  • to show syntax variants simply one after another, without "or" or any kind of comment; simply one line of code per variant (no need to mark optional parameters). No text in the section, only clear code with proper parameter names.
  • to use lowercase (it's a fact it's easier to read and to write) for everything (keywords and parameters).
  • to use camelCase for parameters with compound names (they cannot be reserved words anymore, because of <freebasic>).

You can see and example in the peek page I just rearranged. Note I left both syntax layouts for you to compare. Also the rest of the page is changed to illustrate some of my future suggestions.

Print this item

  First version of RND
Posted by: programandala.net - 06-18-2010, 03:49 PM - Forum: Documentation - No Replies

I've just created the first version of RND. The remarks are adapted from a recent message of boriel, and the examples are taken from FreeBASIC.

Print this item

  RND doesn't accept brackets (*solved*)
Posted by: programandala.net - 06-18-2010, 02:53 PM - Forum: Bug Reports - Replies (3)

I've just realized RND() is not accepted ("Unexpected token '(' <LP>"), but only RND. I know it doesn't have parameters in Sinclair BASIC, but it's a function anyway. In fact, both INKEY and INKEY() are accepted, and the case is analogous.

I took a look at the functions list of the original ZX Spectrum manual (page 198, Spanish edition), and realized that PI is there! I never thougth it was a function, but a constant. Well, I tried PI() Smile in ZX BASIC and it's not accepted, not a surprise.

It's clear PI is a constant (that's the description in the wiki), but what's the difference between RND and INKEY? They both are functions that need no parameter. I think RND() should be accepted, if only for syntax coherence.

(I've just read the FreeBASIC's RND syntax. It's accepted without brackets, but can have an optional parameter, the seed.)

Print this item

  String Adress wrong (*solved*)
Posted by: LCD - 06-18-2010, 12:36 PM - Forum: Bug Reports - Replies (4)

Strangely my proportional Print SUB from Tips section, with example, does not work anymore with the latest development version of ZXBC, because the address of text in b$ is returned incorrectly (in ROM).

Code:
DIM b$ AS STRING
b$="test"
PRINT PEEK(Uinteger,@b$)+2
It does not return the correct address and compiled program says "A Invalid argument" at the end.
Code:
DIM b$ AS STRING
dim adr as uinteger
b$="test"
adr=PEEK(Uinteger,@b$)+2
print adr
Does not change anything.
Code:
adr=@b$
comes with a "Undefined label '_test_b'." if used in SUBs

Print this item

  strings initialized?
Posted by: programandala.net - 06-18-2010, 12:34 PM - Forum: Help & Support - Replies (6)

Yesterday I experienced a kind of coding poltergeist with the following simple function:

Code:
function strings(times as ubyte, text as string ) as string

    dim i as ubyte
    dim result as string
    for i = 1 to times
        let result = result + text
    next i
    return result

end function

The program did strange things when printing the string returned by strings(): it printed other strings of the program that had nothing to do, and then froze. The reason was I had supposed the DIMed strings were initialized to an empty string but they are not; it took time to find out. When I added a simple line, everything worked as expected:

Code:
    dim result as string
    let result = ""

I've searched in the forum, but found no reference about this. The DIM wiki page doesn't mention string initialitazion. I just want to confirm this issue before updating the wiki. Are strings not initialized to empty strings because of a technical issue or simply because it's not implemented yet? Is this definitive or will it change in the future?

Print this item

  INCBIN
Posted by: britlion - 06-18-2010, 03:31 AM - Forum: Help & Support - Replies (1)

Boriel, what's the syntax for including a binary chunk with INCBIN?

Print this item

  Assembler "EQU"
Posted by: britlion - 06-18-2010, 03:24 AM - Forum: Help & Support - Replies (3)

I have some code that has things like

BORDER_CLR: EQU 4

What's the equivalent in your assembly? A #define?

Print this item