Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 384 online users. » 0 Member(s) | 381 Guest(s) Bing, Facebook, Yandex
|
Latest Threads |
Includes in ASM
Forum: How-To & Tutorials
Last Post: bracckets
04-04-2024, 12:17 AM
» Replies: 2
» Views: 685
|
Intermittent errors
Forum: Help & Support
Last Post: zarsoft
03-12-2024, 12:39 PM
» Replies: 0
» Views: 372
|
Store array information i...
Forum: Help & Support
Last Post: rbiondi
03-10-2024, 09:42 PM
» Replies: 0
» Views: 481
|
ScrollLeft function scrol...
Forum: Bug Reports
Last Post: rbiondi
03-07-2024, 03:57 PM
» Replies: 2
» Views: 944
|
string.bas errors when co...
Forum: Bug Reports
Last Post: rbiondi
03-01-2024, 10:10 AM
» Replies: 2
» Views: 831
|
Using Beepola with ZX BAS...
Forum: How-To & Tutorials
Last Post: edtoo
02-29-2024, 09:47 AM
» Replies: 15
» Views: 33,497
|
Johnny Bravo
Forum: Gallery
Last Post: zarsoft
02-11-2024, 11:20 PM
» Replies: 0
» Views: 539
|
Compiling +D G+DOS progra...
Forum: ZX Basic Compiler
Last Post: boriel
01-22-2024, 08:32 AM
» Replies: 4
» Views: 8,877
|
VAL = ? (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:44 PM
» Replies: 8
» Views: 3,600
|
Wrong math (solved)
Forum: Bug Reports
Last Post: zarsoft
01-03-2024, 11:38 PM
» Replies: 4
» Views: 1,970
|
|
|
Wrong #defined calculated value |
Posted by: programandala.net - 06-21-2010, 09:57 AM - Forum: Help & Support
- Replies (3)
|
|
I think there's something I'm missing about the way #define values are calculated, look:
Code: #define screenFirstCol 0
#define screenLastCol 31
#define borderFirstCol screenFirstCol
#define borderLastCol screenLastCol
#define oWinFirstCol borderFirstCol+1
#define oWinLastCol borderLastCol-1
' Wrong result, 32 instead of 30:
#define oWinWidth oWinLastCol-oWinFirstCol+1
cls
print "Expected values in cramps:"
print
print "screenFirstCol(0)=";screenFirstCol
print "screenLastCol(31)=";screenLastCol
print "borderFirstCol(0)=";borderFirstCol
print "borderLastCol(31)=";borderLastCol
print "oWinFirstCol(1)=";oWinFirstCol
print "oWinLastCol(30)=";oWinLastCol
' Wrong result, 32 instead of 30:
print "oWinWidth(30)=";oWinWidth
pause 0
stop
What's the problem?
I think #defined values are simple labels calculated by the preprocessor. Is it right? Is there any limit about the depth of the calculated values?
|
|
|
The complex page about DIM |
Posted by: programandala.net - 06-20-2010, 11:17 PM - Forum: Documentation
- Replies (1)
|
|
I've rearranged the DIM page. It is the most complex page I've seen in the wiki.There were double contents here and there, and no clear order. It seems text was pasted from different sources several times. I tried to reorganize the whole into two subheaders (variables and arrays). I think now the order is clearer, and there are no redundant contents. I linked to the mentioned command line options, and to the pragma page (that doesn't exist yet).
May someone take a look and see, if something is missing or wrong in the contents, the order or the headers? Thank you.
|
|
|
BritLion's High Res Print |
Posted by: britlion - 06-20-2010, 04:00 PM - Forum: How-To & Tutorials
- Replies (18)
|
|
Here's what I've been playing with. Weird that someone else was looking into it too. I have to thank Turkwel over at the WorldOfSpectrum Forums for a LOT of guidance with this one.
This routine prints a character at pixel position (x,y); optionally with attributes.
0 < x < 254
0 < y < 191
If the character is < 256, it assumes you sent an ascii code, and pulls it from the character set. UDG ascii code characters aren't supported in this version (use the address of the UDG - eg. USR "a" instead). If the number is 256 - 65535, it assumes this is an address for a user defined block of data (a character sprite/udg) and plots this data to the screen instead.
If the attribute byte is zero, attributes are skipped, and the routine just updates pixels. I thought, since 0 is black on black, this wasn't too bad a compromise. Otherwise it adjusts the attributes to the byte given. Note that printing one character can adjust up to four attributes!
Note also that this is not a megafast solution to printing sprites. I'm still looking into that option.
There is a Newer version of this and a "sprite" example posted later in this thread.
Code: FUNCTION t() as uLong
asm
DI
LD DE,(23674)
LD D,0
LD HL,(23672)
EI
end asm
end function
SUB HRPrint (x as uByte, y as uByte, char as uInteger, attribute as uByte)
'High res Printing, based on code produced, with thanks, by Turkwel over on the WOS boards.
'Brought to ZX Basic by Britlion, June 2010.
asm
ld b,(IX+7)
ld c,(IX+5)
push BC ; save our co-ordinates.
;print_char:
ld d,(IX+09)
inc d
dec d
jr z, HRPrint_From_Charset
ld e,(IX+08)
jp HR_Print
HRPrint_From_Charset:
ld de,(23606)
ld h,0
ld l,(IX+8) ; character
add hl,hl
add hl,hl
add hl,hl
add hl,de
HR_Print:
call HRPat
;convert the Y and X pixel values to the correct Screen Address - Address in DE
ld a,8
;set counter to 8 - Bytes of Character Data to put down
HRPrint0:
push af
;save off Counter
ld a,b
cp 192
jr c,HRprint1
pop af
jp HRPrintEnd
;don't print character if > 191 - off the bottom of the screen - restore AF and exit Print routine
;[this can be removed if you are keeping tight control of your Y values]
HRprint1:
push hl
push de
push de
;save off Address of Character Data, Screen Address, Screen Address
ld a,c
and 7
ld d,a
;get lowest 3 bits of Screen address
ld e,255
;set up E with the Mask to use - 11111111b = All On
ld a,(hl)
jr z,HRprint3
;get a Byte of Character Data to put down - but ignore the following Mask shifting
;if the the X value is on an actual Character boundary i.e. there's no need to shift anything
HRprint2:
rrca
srl e
dec d
jp nz,HRprint2
;Rotate the Character Data Byte D times - and Shift the Mask Byte as well, forcing Zeroes into the
;Left hand side. The Mask will be used to split the Rotated Character Data over a Character boundary
HRprint3:
pop hl
;POP one of the Screen Addresses (formerly in DE) into HL
ld d,a
ld a,e
and d
;or (hl)
ld (hl),a
;take the Rotated Character Data, mask it with the Mask Byte and the OR it with what's already on the Screen,
;this takes care of the first part of the Byte
;[remove the OR (HL) if you just want a straight write rather than a merge]
inc l
ld a,l
and 31
jr z,HRprint4
;Increment the Screen Address and check to see if it's at the end of a line,
;if so then there's no need to put down the second part of the Byte
ld a,e
cpl
and d
;or (hl)
ld (hl),a
;Similar to the first Byte, we need to Invert the mask with a CPL so we can put down the second part of the Byte
;in the next Character location
;[again, remove the OR (HL) if you just want a straight write rather than a merge]
HRprint4:
pop de
inc d
inc b
;get the Screen Address back into DE, increment the MSB so it points the the Address immediately below
;it and Increment the Y value in B as well
ld a,b
and 7
call z,HRPat
;now check if the Y value has gone over a Character Boundary i.e. we will need to recalculate the Screen
;Address if we've jumped from one Character Line to another - messy but necessary especially for lines 7 and 15
pop hl
inc hl
;get the Address of the Character Data back and increment it ready for the next byte of data
pop af
dec a
jp nz,HRPrint0
;get the Counter value back, decrement it and go back for another write if we haven't reached the end yet
jp HRPrintAttributes
;HRPAT is a subroutine to convert pixel values into an absolute screen address
;On Entry - B = Y Value C = X Value On Exit - DE = Screen Address
HRPat:
ld a,b
srl a
srl a
srl a
ld e,a
and 24
or 64
ld d,a
ld a,b
and 7
add a,d
ld d,a
ld a,e
and 7
rrca
rrca
rrca
ld e,a
ld a,c
srl a
srl a
srl a
add a,e
ld e,a
ret
HRPrintAttributes:
POP BC ; recover our X-Y co-ordinates.
ld d,0
ld a,(IX+11) ; attribute
and a
jr z, HRPrintEnd ; if attribute=0, then we don't do attributes.
ld e,a ; pass to e
;transfer Attribute Byte to e for easier use
ld a,b
cp 192
jr nc, HRPrintEnd
;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
print_attributes1:
ld a,c
cp 248
jr nc,endPrintAttributes1
;check to see if we are at Horizontal character 31 - if so then no need to set adjacent Horizontal Attribute
and 7
jr z, endPrintAttributes1
;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
endPrintAttributes1:
;
ld a,b
cp 184
jr nc, HRPrintEnd
;check to see if we are at Vertical character 23 - if so then no need to set adjacent Vertical Attribute & Exit routine
and 7
jr z, HRPrintEnd
;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
;
HRPrintAttribute2: ld a,c
cp 248
jr nc, HRPrintEnd
;check to see if we are at Horizontal character 31 - if so then no need to set adjacent Horizontal Attribute
and 7
jr z, HRPrintEnd
;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
HRPrintEnd:
end asm
END SUB
CLS
PRINT at 15,0;"Routine Test"
time=t()
FOR y=0 to 100
FOR x=0 to 100
HRPrint(x,y,CODE"2",39)
NEXT x
NEXT y
print (t()-time)/CASt(float,50); " seconds"
|
|
|
"C Nonsense in BASIC" |
Posted by: programandala.net - 06-20-2010, 12:22 AM - Forum: Help & Support
- Replies (5)
|
|
First case
I moved the main loop of my program into a sub, but I forgot to call the sub... so the program had nothing to do after DIMing and LETing some variables. The program returned to Sinclair BASIC with the error "C Nonsense in BASIC" instead of "0 OK".
Then I wrote a test program: just one sub, not called. The program returned to Sinclar BASIC with "0 OK". Strange. So there's something wrong with my program.
If I call the sub, or take its content out of the sub, everything works fine.
Second Case
But then I moved the main loop (out of any sub) to the end of the program... and the same error happened. I suspected two files I'm including, with character sets in assembler format, had something to do.
Here you are schematic versions of both cases:
This one works fine:
Code: ' ....most of the program here......
do
' MAIN LOOP
loop
#include "charset1.bas"
#include "charset2.bas"
def sub charset()
' bla bla
end sub
' END OF FILE
But this one simply returns with "Nonsense in basic":
Code: ' ....most of the program here......
#include "charset1.bas"
#include "charset2.bas"
def sub charset()
' bla bla
end sub
do
' MAIN LOOP
loop
' END OF FILE
Both included files have the same structure:
Code: label:
asm
defb 1,8,86,68,78,78,78,6
; hundreds of DEFB
defb 1,8,86,68,78,78,78,6
end asm
So?
Both cases are not the same, but I suspected the included files are the reason of the strange error in the first case, when there was nothing to exectute; and the fact than the main loop is not found in the second case, and the error is returned.
I kept the main loop at the end of the program and removed the #includes. The program worked fine! Case 2 confirmed.
Then I moved the main loop into a sub but didn't called the sub... The program returned with a "0 OK" message as expected! Case 1 confirmed.
Will it happen with explicit (not #included) ASM sections? Let's see. I added some assembler lines right before the main loop sub, but the message was still "0 OK". It seems the strange behaviour is caused by #including the ASM sections.
Am I doing something wrong? Is there any limitation about the location of ASM sections or its including?
|
|
|
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
'---
'==========================
|
|
|
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.
|
|
|
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.
|
|
|
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.
|
|
|
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() 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.)
|
|
|
|