Single pixel motion in high res?
Re: Single pixel motion in high res?
You set HL and do the display
You set HL and do the display
You wait
You erase with second HL
You erase with second HL (not first calculated)
This causes the flasing
You set HL and do the display
You wait
You erase with second HL
You erase with second HL (not first calculated)
This causes the flasing
Re: Single pixel motion in high res?
Improved code and some movement
Code: Select all
ORG #4009 ;#4009
; program starts here, both BASIC and machinecode
basic EX AF,AF' ; delay intrupt,opcode no bit 6
LD H,B ; preset for 48K bug to #40
JR init0 ; continue where room
DEFB 236,212,28 ; The BASIC
DEFB 126 ; fully placed over sysvar
DEFB 143,0,18 ; start BASIC=#4009 also MC
DEFW last ; needed by loading
chadd DEFW last-1
xptr DEFW 0
stkbot DEFW last
stkend DEFW last
berg DEFB 0
mem DEFW 0
DEFB 128
DEFB 0,0,0
; all above reusable AFTER loading
lastk DEFB 255,255,255 ; used by ZX81
margin DEFB 55 ; used by ZX81
nxtlin DEFW basic ; reusable after load
nop
defb #40,#40,#40
nop
taddr DEFW 0 ; used by ZX81 on LOAD only
; unharmed code
DEFW 0
frames
DEFB 255
DEFB 255 ; highbyte must have bit 7 set
coords DEFW 0
prcc DB 0,0,0
cdflag DEFB 64 ; used by ZX81
;-------------------------------------------------------------------
; Place ANY code to fill up to #4040
; init
init0
ld ix,hr
ld hl,screen
ld de,screen+1
ld (hl),0
ld bc,6143
ldir ; clear hires screen
;-------------------------------------------------------------------
; game loop
ld bc,#400
ploop push bc
ld de,myudg1
call mydisplay
ld a,c
add a,8
ld c,a
ld de,myudg2
call mydisplay
call mydelay
pop bc
ld de,myudg1
call mydisplay
ld a,c
add a,8
ld c,a
ld de,myudg2
call mydisplay
jr ploop ; do playloop
;-------------------------------------------------------------------
; mydisplay
mydisplay
call scrad ; calculate screen address
;-------------------------------------------------------------------
; show/erase udg
prudg push bc ; save coordinates
ld b,8
prudg1
ld a,(de) ; get udg
xor (hl) ; xor udg on screen
ld (hl),a ; write on screen
inc de
inc hl
ld a,(de) ; also second position
xor (hl)
ld (hl),a
inc de
ld a,l
add a,31 ; move to next line on screen
ld l,a
jr nc,bdec
inc h ; next block on screen when needed
bdec djnz prudg1
pop bc ; get coordinates back
ret
;-------------------------------------------------------------------
; delay
mydelay
push hl
ld hl,frames
ld a,(hl)
sub 5 ; lower number will speed up game.
mywait
cp (hl)
jr nz,mywait ; wait some time
pop hl
ret
;-------------------------------------------------------------------
; calculate screenaddress for XY-pos in BC (optimized in speed)
; Right address = SCREEN + B*32 + INT (C/8)
; B*32 = B/8 where B MOD 8 must be in 3 highbits C
scrad push bc
srl b ; B / 2
rr c ; Bit 0 from B in bit 7 C, and C/2
srl b ; B / 2, now B = B/4
rr c ; Bit 0 from B in bit 7 C, and C/2, C= C/4
srl b ; B / 2, now B = B/8
rr c ; Bit 0 from B in bit 7 C, and C/2, C= C/8
ld hl,screen ; BC now B*32+ INT (C/8), now we need start of screen too
add hl,bc ; HL now screenaddress
pop bc
ret
;-------------------------------------------------------------------
; some lowres, HR must start AFTER #403F, but before #4070
hr LD HL,lowres+#8000 ; the lowres display
LD BC,#211 ; 1 line lowres text
LD A,#1E
LD I,A
LD A,#Fb
CALL #2B5 ; show lowres screen
LD B,11 ; match hires display with lowres
hr00 DJNZ hr00
ld hl,screen-32 ; start of hiresscreen (must be NNX0) where X = 0 2 4 8 A C E
ld de,32 ; screen line length
;-------------------------------------------------------------------
; the hr part
ld b,176 ; display 176 lines
hr1 add hl,de ; next line
ld a,h ; preset first line to show
ld i,a ; set highbyte of display (always the same)
call lbuf+#8000
dec b
jp nz,hr1
; fixed end of HR-routine
exit CALL #292 ; back from intrupt
CALL #220
LD IX,hr
JP #2A4
lbuf ld a,l
ld r,a
block 32,0
ret nc
;-------------------------------------------------------------------
lowres db 118
db "T"+101,"E"+101,"S"+101,"T"+101,0,"W"+101,"I"+101,"T"+101
db "H"+101,0,"U"+101,"D"+101,"G"+101
db 118
mycoord1 db 128,92 ; middle of the screen
mycoord2 db 128,74
myudg1
db %00011000,0
db %00101100,0
db %00111100,0
db %00011000,0
db %00111100,0
db %00101100,0
db %01011110,0
db %01111110,0
myudg2
db %11111111,0
db %10000001,0
db %10000001,0
db %10000001,0
db %10000001,0
db %10000001,0
db %10000001,0
db %11111111,0
vars db 128
last equ $
screen equ #6000 ; somewhere far away in memory
Re: Single pixel motion in high res?
BTW,
your current code does not have horizontal pixelmovement
your current code does not have horizontal pixelmovement
Re: Single pixel motion in high res?
Dr Beep, thank you very much for sharing your knowledge, that's so kind.
I understand better now, and it is working fine.
I don't need any hor/vert movement because I intend to
use UDGs to form a chessboard, so position will be static.
I used your pixelmotion highres example (above in this post)
because the code was short and well explained. But for this
project I don't really need pixelmotion (well you never know).
I (painfully) studied some of your other hires game source code,
and tried to simplify them to get something basic (not the langage)
so I can understand, but I must say your code is so advanced (you
may not realize because you're into it for so many years) that
I'm often struggeling ! That's why I love your 1k book, and
especially the tutorial you offered us a few years ago, with
a simple lowres game developed piece after piece ('catch the pixel').
One question for this code, I don't get why calling again display
after the delay is erasing the UDG ? Normally you should write
a blank character to erase, don't you ?
I understand better now, and it is working fine.
I don't need any hor/vert movement because I intend to
use UDGs to form a chessboard, so position will be static.
I used your pixelmotion highres example (above in this post)
because the code was short and well explained. But for this
project I don't really need pixelmotion (well you never know).
I (painfully) studied some of your other hires game source code,
and tried to simplify them to get something basic (not the langage)
so I can understand, but I must say your code is so advanced (you
may not realize because you're into it for so many years) that
I'm often struggeling ! That's why I love your 1k book, and
especially the tutorial you offered us a few years ago, with
a simple lowres game developed piece after piece ('catch the pixel').
One question for this code, I don't get why calling again display
after the delay is erasing the UDG ? Normally you should write
a blank character to erase, don't you ?
Re: Single pixel motion in high res?
You are setting the UDG with XOR (HL).
Doing this twice will erase the first display.
Doing this twice will erase the first display.
Re: Single pixel motion in high res?
The 1K hires routines are optimized for the 1K use and therefore harder to read than the normal 16K WRX from Wilf Rigter.
I know how all 1K grew over the years and some routines
are really tight in code and therefore hard to read.
A game like BREAKOUT has by heart 7 paths in the display all to fit in exactly 207 tstates to sync the display.
I know how all 1K grew over the years and some routines
are really tight in code and therefore hard to read.
A game like BREAKOUT has by heart 7 paths in the display all to fit in exactly 207 tstates to sync the display.
Re: Single pixel motion in high res?
Now I understand how the XOR works thanks.
Here is the actual code following your instructions, not optimized of course.
This is just showing the display board, no algorythm for now.
the corresponding p file
The whole screen flickers when hitting enter, is this normal, should I switch to fast mode ?
Here is the actual code following your instructions, not optimized of course.
This is just showing the display board, no algorythm for now.
the corresponding p file
The whole screen flickers when hitting enter, is this normal, should I switch to fast mode ?
Re: Single pixel motion in high res?
The flickering is because you erase the entire board.
Since this is chess you better only move the piece you selected.
A piece can hit a new piece so you better alter the display and skip the XOR (HL) and only place the piece LD A,(DE) LD (HL),A
This also needs an erasing UDG into an empty field black or white
Since this is chess you better only move the piece you selected.
A piece can hit a new piece so you better alter the display and skip the XOR (HL) and only place the piece LD A,(DE) LD (HL),A
This also needs an erasing UDG into an empty field black or white
Re: Single pixel motion in high res?
Good advices, thank you !
Re: Single pixel motion in high res?
Since you are displaying the full board and also the empty fields you can als simply place a full new board without erasing.
this will take away the flashing and give right result.
I do that in my 1K game Shogun.
this will take away the flashing and give right result.
I do that in my 1K game Shogun.