A82: Re: a82: writing to the display port!!!


[Prev][Next][Index][Thread]

A82: Re: a82: writing to the display port!!!



Below you will find a short disribtion of how the problem could be solved,
and some code to implement this. I have not tested the code (i was not near
any z80 books or ti82 files when i wrote this) so it might contain some
errors, but you should be able to get the idea. Most of the code can be
optimized so it will run faster than what i have written, but doing this
would make the code harder to understand. It should not be hard to optimize
the code, as long as you understand what is going on. I included some
comments to the code, but i was in a hurry when i wrote it so there migh not
be enough. If there are eny parts of the code that you do not understand,
just mail the questions and i will answer them. So here we go ...

 Instead of defining the paddle as you wrote, try doing this :

Define two variables in the text_mem, a byte called curcol and a word called
bitmap. Curcol will contain the current column of the paddle, and bitmap the
bitmap to display.

When you want to move the paddle to the left, check if the first byte of
bitmap is 0FFh, if it is decrease curcol and set bitmap to 00h,FFh (unless
curcol was allready 0, if it was do nothing). If the byte was <> 0FFh shift
bitmap once. When this is done draw the bitmap.

When you want  to move the paddle to the left do the same thing, but just in
the other direction.

So the source could look something like this.

Bitmap = TEXT_MEM     ; Define vars in text mem
Curcol = TEXT_MEM+2

LD A,$8C  ; Set rompage
OUT (2),A
ROM_CALL(CLEARLCD) ;clear display
Init:   ;Initialize vars in textmem
  ld hl,TEXT_MEM
  ld (HL),$FF ; Set bitmap to 1111111100000000b
  inc hl
  ld (HL),$00
  inc hl
  ld (HL),$26 ; Set position to column 6 (you have to add $20 to the column)
  call UP_PADDLE ;Draw paddle
Main:
  ;Insert code which moves paddle here

; Move_right moves paddle right
; Move_left moves paddle left
; UP_PADDLE draw the paddle

Move_right:
   LD HL,(Bitmap) ;Get current bitmap
   LD A,L
   CP A,$FF ; Is paddle all the way to the right ?
   JR Z,MRCol ; Yes goto next col
   SRL H ;Shift HL right
   RRC L
  LD (Bitmap),HL ;Save new bitmap
  JR UP_PADDLE  ;Update scren
MRCol:
  LD A,(Curcol) ; Getcurrent position
  CP $2A ;If we are all the way to the right we can not move more
  ret z ; so return
  inc a
  ld (Curcol),a ;Save new position
  ld hl,$FF00 ;Set new bitmap
  ld(Bitmap),HL
  jr UP_PADDLE ;Show it

Move_left:
   LD HL,(Bitmap) ;Get current bitmap
   LD A,H
   CP A,$FF ; Is paddle all the way to the left ?
   JR Z,MLCol ; Yes goto next col
   SLA L ;Shift HL left
   RLC L
  LD (Bitmap),HL ;Save new bitmap
  JR UP_PADDLE  ;Update scren
MLCol:
  LD A,(Curcol) ; Getcurrent position
  CP $20 ;If we are all the way to the left we can not move more
  ret z ; so return
  dec a
  ld (Curcol),a ;Save new position
  ld hl,$00FF ;Set new bitmap
  ld (Bitmap),HL
  jr UP_PADDLE ;Show it

UP_PADDLE:
  ld a,5       ; make cursor move right every time we write a byte
  call $7F3 ;do thid before all writes to port 10/11
  out (10h),a
  ld a,(Curcol) ; get current column
  call $7F3 ;do thid before all writes to port 10/11
  out (10h),a    ; set  column
  ld a, $BD ; Third line from the bottom
  call $7F3 ;do thid before all writes to port 10/11
  out (10h),a ;goto it
  ld hl,(Bitmap) ;get bitmap
  ld a,h ;write first part of bitmap
  call $7F3 ;do thid before all writes to port 10/11
  out (11h),a
  ld a,l ;write second part of bitmap
  call $7F3 ;do thid before all writes to port 10/11
  out (11h),a
  ld a,(Curcol) ; get current column
  call $7F3 ;do this before all writes to port 10/11
  out (10h),a    ; set  column
  ld a, $BE ; Second line from the bottom
  call $7F3 ;do thid before all writes to port 10/11
  out (10h),a ;goto it
  ld hl,(Bitmap) ;get bitmap
  ld a,h ;write first part of bitmap
  call $7F3 ;do thid before all writes to port 10/11
  out (11h),a
  ld a,l ;write second part of bitmap
  call $7F3 ;do thid before all writes to port 10/11
  out (11h),a
  ret

I hope this helps you, but remember this is not optimized code it is meant
to help you understand how a fast rutine could be written.

Dines

-----Original Message-----
From: GSGolfNut@aol.com <GSGolfNut@aol.com>
To: assembly-82@lists.ticalc.org <assembly-82@lists.ticalc.org>
Date: 18. september 1997 00:50
Subject: A82: a82: writing to the display port!!!



>I need a fast routine for putting pixels to the display port explained in
>detail, starting with changing the rom page. What I want to do is make a
>paddle move back and forth across the screen. The paddle would look like
>this:
>.db 11111111b
>.db 11111111b
>Thanks
>Gerad.
>
>


Follow-Ups: