06-22-2003, 04:09 AM
I developed a simple toolkit for textmode:
You can directly write to screen 0 using:
Where x% and y% are the coordinates, foreground% and background% are the colours, and chr% is the ASCII code of the char you wanna print.
But this is really suited to use an offscreen text mode buffer:
To blit the buffer to screen you can use (for example) the superb memcopy routine by Jonathan L. Leger ::
You just call the rutine to blit your buffer this way:
I used all those techniques in my textmode game (that I've posted here a couple of times, but it seems that nobody has seen it):
··<[ Nadya ]>··
Code:
SUB PutChar (dSeg%, dOff%, x%, y%, c%, chr%)
DEF SEG = dSeg%
POKE dOff% + 160 * y% + 2 * x% + 1, c%
POKE dOff% + 160 * y% + 2 * x%, chr%
DEF SEG
END SUB
You can directly write to screen 0 using:
Code:
PutChar &HB800, 0, x%, y%, foreground%+background%*16, chr%
Where x% and y% are the coordinates, foreground% and background% are the colours, and chr% is the ASCII code of the char you wanna print.
But this is really suited to use an offscreen text mode buffer:
Code:
DIM Buffer%(1999)
PutChar VARSEG(Buffer%(0)), VARPTR(Buffer%(0)), x%, y%, foreground% + background%*16, chr%
To blit the buffer to screen you can use (for example) the superb memcopy routine by Jonathan L. Leger ::
Code:
'===========================================================================
' Subject: PATCHED MEMCOPY ROUTINE Date: 02-27-98 (00:57)
' Author: Jonathan L. Leger Code: QB, QBasic, PDS
' Origin: leger@earthlink.net Packet: MEMORY.ABC
'===========================================================================
defInt A-Z
DECLARE SUB initMemCopy ()
DECLARE SUB memCopy (fromseg%, fromoffset%, toseg%, tooffset%, bytes%)
DECLARE SUB fillChar (segment%, offset%, value%, bytes%)
DIM SHARED memCopy.ASM AS STRING
Dim Array1(1 To 1000) As Integer
Dim Array2(1 To 1000) As Integer
initMemCopy
'*** Fill the first array.
For Value = 1 To 1000: Array1(Value) = Value: Next Value
'*** Copy the contents of Array1() into Array2()
a1seg = VARSEG(Array1(1)) '*** Segment location of Array1()
a1off = VARPTR(Array1(1)) '*** Offset of Array1()
a2seg = VARSEG(Array2(1)) '*** Segment location of Array2()
a2off = VARPTR(Array2(1)) '*** Offset of Array2()
bytes = 2000 '*** Number of bytes (integer = 2 bytes)
memCopy a1seg, a1off, a2seg, a2off, bytes
'*** Show second array's contents.
For Value = 1 To 1000: Print Array2(Value);: Next Value
End
defSng A-Z
Sub initMemCopy()
memCopy.ASM = ""
memCopy.ASM = memCopy.ASM + Chr$(85) 'PUSH BP
memCopy.ASM = memCopy.ASM + Chr$(137) + Chr$(229) 'MOV BP,SP
memCopy.ASM = memCopy.ASM + Chr$(30) 'PUSH DS
memCopy.ASM = memCopy.ASM + Chr$(139) + Chr$(70) + Chr$(10) 'MOV AX,[BP+0A]
memCopy.ASM = memCopy.ASM + Chr$(142) + Chr$(192) 'MOV ES,AX
memCopy.ASM = memCopy.ASM + Chr$(139) + Chr$(70) + Chr$(14) 'MOV AX,[BP+0E]
memCopy.ASM = memCopy.ASM + Chr$(142) + Chr$(216) 'MOV DS,AX
memCopy.ASM = memCopy.ASM + Chr$(139) + Chr$(118) + Chr$(12) 'MOV SI,[BP+0C]
memCopy.ASM = memCopy.ASM + Chr$(139) + Chr$(126) + Chr$(8) 'MOV DI,[BP+08]
memCopy.ASM = memCopy.ASM + Chr$(139) + Chr$(78) + Chr$(6) 'MOV CX,[BP+06]
memCopy.ASM = memCopy.ASM + Chr$(243) 'REPZ
memCopy.ASM = memCopy.ASM + Chr$(164) 'MOVSB
memCopy.ASM = memCopy.ASM + Chr$(31) 'POP DS
memCopy.ASM = memCopy.ASM + Chr$(93) 'POP BP
memCopy.ASM = memCopy.ASM + Chr$(203) 'RETF
End Sub
defInt A-Z
Sub memCopy(fromseg%, fromoffset%, toseg%, tooffset%, bytes%)
DEF SEG = VARSEG(memCopy.ASM)
Call Absolute(byVal fromseg%, byVal fromoffset%, byVal toseg%, byVal tooffset%, byVal bytes%, SADD(MemCopy.ASM))
DEF SEG
End Sub
You just call the rutine to blit your buffer this way:
Code:
memCopy VARSEG(Buffer%(0)), VARPTR(Buffer%(0)), &HB800, 0, 2000
I used all those techniques in my textmode game (that I've posted here a couple of times, but it seems that nobody has seen it):
··<[ Nadya ]>··
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i