"Storing data to the VDC Screen.." 80columns How too?

Started by stiggity, July 22, 2010, 12:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

stiggity

Hello:
Im in the process of writing a BBS program for the 128, and im wondering how i would store bytes to the screen. I know a STA SCREEN isnt going to work on the VDC, and i remember reading how you have to BIT the VDC control register to get data to the screen..I would like to have a "window" with a 8 to 10 function "lightbar" (press the arrow keys left/right to scroll lightbar, and up arrow selects, down arrow un-selects, and i also have no system clock. Right now im not using the IRQ and plan to vectoring in a clock and lightbar, but i have no clue how.. been reading mapping the 128, and contantly using my 128 PRM.. any insight??

-Thank You
-Steve

Payton Byrd

For printing characters to the VDC directly you need to plot them directly into the appropriate screen memory location of the VDC RAM following the technique I used to copy data around in the VDC for CBM-Command.  Look at the code in this URL for guidance:


http://cbmcommand.codeplex.com/SourceControl/changeset/view/49966#829975
Payton Byrd
---------------------------------------------------
Flat 128 w/JD, uIEC/SD, uIEC-CF/IDE,
1541 Ultimate, 1571 w/JD, 1581 w/JD,
VDC-SVideo, Visio 19" HDTV

stiggity

Payton:
Thanks for the link to the source but what i want to do is very similar to C-Net 128. Where while the user is at _any_ input promps, there idle time will be stored to "screen memory" untill they press a key. And im working on a TOD clock, and need an interrupt driven means to keeping the clock up-top and constantly running.. i'll look at your source more. What assembler did u use to write that??? Im not the best at ML and im finding it hard to navigate yer code.. sorry..

-Steve

Payton Byrd

Quote from: stiggity on July 22, 2010, 05:03 AM
Payton:


What assembler did u use to write that??? Im not the best at ML and im finding it hard to navigate yer code.. sorry..

-Steve
It's written for ca65, which is the assembler portion of the cc65 library.
Payton Byrd
---------------------------------------------------
Flat 128 w/JD, uIEC/SD, uIEC-CF/IDE,
1541 Ultimate, 1571 w/JD, 1581 w/JD,
VDC-SVideo, Visio 19" HDTV

stiggity

Payton:
As another satisfied gui4cbm4win customer i have to thank you for that program. I use it all the time. could you maybe give me an example of how to store a byte onto the screen? maybe a simple lda#65 and then how do i store the "a" to the upper left hand corner?

-Steve
P.S
I use 64tass to dabble in assem..

LokalHorst

Example:

LDA #>addr. ;VDC mem addr. hi
LDX #$12 ;vdc-reg 18
JSR $CDCC ;rom routine
LDA #<addr. ;VDC mem addr. lo
INX  ;vdc-reg 19
JSR $CDCC
LDA #'a'
JSR $CDCA ;store to vdc-reg 31 (data)
repeat the above call if more than 1 char is going to be written (vdc-mem pointer advances automatically with each read/write to reg 31)
...

default screen is located @ $0000 (top-left) to $07cf (bottom-right) in VDC-mem


stiggity

Lokal:
Thanks so much for the example code, i've been messing with it all day. Got another question. IN your source u have "addr" i made this $0000 and some others and its worked fine, how could i do it where lets say i want to store 4 characeters from a buffer, to somewhere on the screen besides $0000. i guess what im asking is.. i want to keep the length down as much as possible, and i know there is a better way of doing the store, without having to type that routine in _every_ time  i need to store data to the screen.. if i confused you, don't worry Im confused too. Sorta wanna do a lda $0300 sta "addr" or something..

LokalHorst

The addr. setup defines the starting position if you like.
If you want to put a string that way - it looks like this
LDA #>addr. ;VDC mem addr. hi
LDX #$12 ;vdc-reg 18
JSR $CDCC ;rom routine set vdc-reg in X to value in A
LDA #<addr. ;VDC mem addr. lo
INX  ;vdc-reg 19
JSR $CDCC
LDY #$00
loop:
LDA (ZP),Y
JSR $CDCA
INY
CPY #len
BCC loop
...

stiggity

Lokal:
Im in the process of writing a "13 option lightbar" for the sysop to poke around and pop into chat, boot a user, give more time, decrease time, shut-down certain area's etc.. the routine i used on the 64 had _alot_ of STA SCREENMEMORY is there anyway to store the starting position in a label, via a STA command. Reason being, i could write your routine once, and use it for everything..

-Steve

LokalHorst

#9
I don't know if I understood correctly - of course the position is variable and can be hold in any storage location (lda $whatever hi / lda $ whatever lo)
For your purpose I would suggest something else - if the status line is more or less static, copy it to an unused location in VDC-mem (between $1000 and $2000) and do block copy operation from there to the visible screen. (VDC has special registers for that)
My example left out the attribute memory - each char location has an associated location in attribute memory (default VDC-mem from $0800 to $0FCF) where color, blink, underline, revers is defined. For a menu-bar usually the selection is highlighted (reversed) in this case you wouldn't write the chars, but values to the attribute mem.

stiggity

Lokal:
rihgt now im using the..

LDA #>addr. ;VDC mem addr. hi
LDX #$12 ;vdc-reg 18
JSR $CDCC ;rom routine set vdc-reg in X to value in A
LDA #<addr. ;VDC mem addr. lo
but in order to store to another area on the VD screen i have to type this in again, and again.. is there anyway i could do something like this.

lda     $0000
sta     addr or.. lda    $07c0sta    addr that way i can just JSR to your routine and the screen memory location is updated with the label "addr"does that make any sense?? -Steve

LokalHorst

Not really - I gave an example, not a general purpose routine.
But after a short look to the forum section "VDC-Programming" I found one, see:

;set up VRAM address
;
;   .X = VRAM address LSB
;   .Y = VRAM address MSB
;
;   registers preserved
;
setadr   pha                   ;preserve registers
         txa
         pha
         tya                   ;VRAM address MSB
         ldx #$12           ;select VRAM address register MSB (18)
         jsr writereg          ;$cdcc set address MSB
         pla                   ;VRAM address LSB
         inx               ;select VRAM address register LSB (19)
         jsr writereg          ;$cdcc set address LSB
         tax                   ;restore
         pla                   ;likewise
         rts

In the above you have to provide the addr. in X=lo and Y=hi (writereg equ. jsr $cdcc)
I thought you would come to such a conclusion yourself.

stiggity

Lokalhorst:
man.. i _had_ this working in just a plain example, but when i incorporated it into my code, it garbles the screen and everything is messed up. Could you take  look and see whats wrong..


writereg = $CDCC

lef0 tya
pha
ldx #$40
ldy #$01
jsr setaddr
pla
tay

ldx #0
lefa cpx #3
beq leftd
lda bar,y
jsr $CDCA
inx
iny
jmp lefa

leftd rts


setaddr   pha                 
         txa
         pha
         tya                   
         ldx #$12           
         jsr writereg         
         pla                   
         inx               
         jsr writereg         
         tax               
         pla                 
         rts

bar     .text    "My light bar data.... 40characters of it.."

LokalHorst

#13
The cpx# is the culprit, as X is used by the writereg and writedata $cdca (then X is set to $1f) subs. You can change the setaddr in a way that it takes A and X as input, then you wouldn't need to save Y with tya/pha at the beginning, X is used/modified by the writereg/writedata subs thus has to be saved if in use by the main prog.
(take a look with the build-in ML-monitor with D $fcdca and following)

stiggity

 *=$1300
writereg = $CDCC

jsr libari
sei
  lda  #<clock1
  sta  $0314
  lda  #>clock1
  sta  $0315
  cli
rts
CLOCK1 jsr lbstart
jmp $FA65
lbstart lda $D5
cmp #88
beq getout
cmp lastkey
beq getout
sta lastkey
cmp #85 ;F3
BNE LBARF5
jmp mleft
LBARF5 CMP #86 ;f5
BNE LBARF7
;jmp mright

LBARF7 CMP #83 ;f7
BNE getout
;jmp select
GETOUT STA LASTKEY
JMP LBEXIT
lbexit sta lastkey
rts
mleft dec lbpos
lda lbpos
cmp #12
bcs setl
cmp #0
bcc setl1
jmp ml2
setl lda #0
sta lbpos
jmp ml2
setl1 lda #12
sta lbpos
ml2 tay
lda lbpos1,y
tay
cmp #0
bne com1
jmp lef0
com1 cmp #3
bne com2
jmp lef1
com2 cmp #6
bne com3
jmp lef2
com3 cmp #9
bne com4
jmp lef3
com4 cmp #12
bne com5
jmp lef4
com5 cmp #15
bne com6
jmp lef5
com6 cmp #18
bne com7
jmp lef6
com7 cmp #21
bne com8
jmp lef7
com8 cmp #24
bne com9
jmp lef8
com9 cmp #27
bne com10
jmp lef9
com10 cmp #30
bne com10
jmp lef10
com11 cmp #33
bne com12
jmp lef11
com12 cmp #36
bne com13
jmp lef12
com13 jmp lbexit

lef0 tya
pha
ldx #$01
ldy #$40
jsr setadr
pla
tay

ldx #0
lefa cpx #2
beq leftd
lda bar,y
jsr $CDCA
inx
iny
jmp lefa

leftd jmp lbexit
lef1 jmp lbexit
lef2 jmp lbexit
lef3 jmp lbexit
lef4 jmp lbexit
lef5 jmp lbexit
lef6 jmp lbexit
lef7 jmp lbexit
lef8 jmp lbexit
lef9 jmp lbexit
lef10 jmp lbexit
lef11 jmp lbexit
lef12 jmp lbexit


LIBARI lda #19
jsr $ffd2
lda #13
jsr $ffd2
jsr $ffd2
jsr $ffd2
;jsr $ffd2
;jsr $ffd2

LDY #0
STARTz LDA TEXT,Y
BEQ START1
JSR $FFD2
INY
JMP STARTz

START1 lda #1
sta lbpos
rts





TEXT .BYTE 19,14,17,17,17,17,17,18
.TEXT " LO CH AC TR NU UD SB SY PF U1 U2 TE QT "
.BYTE 146,0
LBPOS1 .BYTE 0,3,6,9,12,15,18,21,24,27,30,33,36
bar .text  " LO CH AC TR NU UD SB SY PF U1 U2 TE QT "
lbpos .byte 0
lastkey .byte 0
;ldx #$40
;ldy #$01
;jsr setadr


setadr   pha                   ;preserve registers
         txa
         pha
         tya                   ;VRAM address MSB
         ldx #$12           ;select VRAM address register MSB (18)
         jsr writereg          ;$cdcc set address MSB
         pla                   ;VRAM address LSB
         inx               ;select VRAM address register LSB (19)
         jsr writereg          ;$cdcc set address LSB
         tax                   ;restore
         pla                   ;likewise
         rts


this is the entire routine, broken down from the main routine, into 1 routine that the IRQ can be activated, and pressing the left arrow doesnt store any data like it should, but once its pressed 4 or 5 times the entire program crashes..

LokalHorst

I can't really follow, but I can say that it doesn't work, because if you modify the update address in the IRQ with happens asynchronous to the main-prog. which expects to have the update address somewhere else upon writing to screen, will create a complete mess of the screen. The minimum measure against would be to preserve the VDC-registers which will be modified/used inside the IRQ.
(readreg X return in A = $cdda, readdata (reg 31) = $cdd8)

BigDumbDinosaur

Try using the 80 Column Display Manager.  It appears you may be reinventing the wheel with all this VDC stuff.
x86?  We ain't got no x86.  We don't need no stinking x86!

stiggity

Lokal:
I got it working... very lame, but working.. ehehhe once i created a byte to swap the x register it all came together.. kind of. the question i have for you.. how do you store a COLOR to VDC screen memory?
my entire lightbar is "reverse/CYAN" and i want the increments to be in reverse/WHITE.. any extra assistance will be gladly noted.. eheh :)

-Steve

stiggity

I was reading, and the book said u have to set bit 4 or something?? i forge the page, and book right now, but im assuming it cant be that hard?? anyone??

-Steve