Enterprise Forever
:UK => Programming => Topic started by: ssr86 on 2016.July.07. 21:14:12
-
Below is the code I'm using for my lpts in one of current projects. I switch them inside the interrupt.
My problem is that the first frame after the lpt switch is displayed one line late (or more that the first line is skipped and the display starts from the second line) and the next frame is displayed as should. This makes the display shake vertically.
What am I doing wrong?
I'm using charmode with all 288 display lines.
Seems that I'm being late with the lpt switch... but I don't think I had this problems with pixel mode displays...
; 160 x 144 4c with 2x2 pixels
SCREEN_HEIGHT equ 144
CHAR_HEIGHT equ 8
current_charmap_address dw CHARMAP1_CPU_ADDRESS
current_font_address dw FONT1_CPU_ADDRESS
dbuff_offset dw $0000
first_buffer_address dw CHARMAP1_CPU_ADDRESS
second_buffer_address dw CHARMAP2_CPU_ADDRESS
first_font_address dw FONT1_CPU_ADDRESS
second_font_address dw FONT2_CPU_ADDRESS
prepare_lpt:
;;copy lptab data in the right place
ld de,LPT1_CPU_ADDRESS
ld hl,lptab_data
ld bc,entab_data-lptab_data
ldir
; copy font
ld hl,font_lvl1
ld de,FONT1_CPU_ADDRESS
ld bc,256*8
ldir
ld hl,font_lvl1
ld de,FONT2_CPU_ADDRESS
ld bc,256*8
ldir
; copy charmap
ld hl,charmap
ld de,CHARMAP1_CPU_ADDRESS
ld bc,40*144/8
ldir
ld hl,charmap
ld de,CHARMAP2_CPU_ADDRESS
ld bc,40*144/8
ldir
ret
set_ingame_lpt_1:
ld a,LOW((LPT1_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
OUT (LPL),A ;set up line parameter pointer
ld a,(lpt_nick_start_addr+1)
add a,HIGH((LPT1_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
OUT (LPH),a ;ensure LP counter is loaded (clk=0, load=0)
OR LPCLOCK ;(clk=1)
OUT (LPH),A
OR LPLOAD ;(load=1)
OUT (LPH),A ;then let it run
ret
set_ingame_lpt_2:
ld a,LOW((LPT2_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
OUT (LPL),A ;set up line parameter pointer
ld a,(lpt_nick_start_addr+1)
add a,HIGH((LPT2_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
OUT (LPH),a ;ensure LP counter is loaded (clk=0, load=0)
OR LPCLOCK ;(clk=1)
OUT (LPH),A
OR LPLOAD ;(load=1)
OUT (LPH),A ;then let it run
ret
lpt_nick_start_addr
screen1_nick_start_addr dw $0000
screen_lpt equ 0000h
charmap1_addr equ CHARMAP1_CPU_ADDRESS-SCREEN_CPU_ADDRESS
charmap2_addr equ CHARMAP2_CPU_ADDRESS-SCREEN_CPU_ADDRESS
font1_addr equ FONT1_CPU_ADDRESS-SCREEN_CPU_ADDRESS
font2_addr equ FONT2_CPU_ADDRESS-SCREEN_CPU_ADDRESS
CHAR_MODELINE macro charline_number,font_addr,charmap
line_number defl 0
rept CHAR_HEIGHT
db 256-1
db CH256+C4
db LEFT_MARGIN
db RIGHT_MARGIN
dw charmap+CHARS_PER_LINE*charline_number
dw font_addr/256+line_number
db COLOR00, COLOR01, COLOR02, COLOR03, COLOR04, COLOR05, COLOR06, COLOR07
db 256-1
db CH256+C4
db LEFT_MARGIN
db RIGHT_MARGIN
dw charmap+CHARS_PER_LINE*charline_number
dw font_addr/256+line_number
db COLOR00a, COLOR01a, COLOR02a, COLOR03a, COLOR04a, COLOR05a, COLOR06a, COLOR07a
line_number defl line_number+1
endm
endm
lptab_data:
lpt_1:
charline_number defl 0
rept SCREEN_HEIGHT/CHAR_HEIGHT
CHAR_MODELINE charline_number,font1_addr,charmap1_addr
charline_number defl charline_number+1
endm
;; sync block:
;; size of bottom border [3 lines]
db 256-3,18,63,0,0,0,0,0,0,0,0,0,0,0,0,0
;; sync on [4 lines]
db 256-4,16,6,63,0,0,0,0,0,0,0,0,0,0,0,0
;; sync off at half line [1 line]
db 256-1,16,63,32,0,0,0,0,0,0,0,0,0,0,0,0
;; blank [4 lines]
db 256-4,18+VINT,6,63,0,0,0,0,0,0,0,0,0,0,0,0
;; size of top border [12 lines]
db 256-12,19,63,0,0,0,0,0,0,0,0,0,0,0,0,0
lpt_2:
charline_number defl 0
rept SCREEN_HEIGHT/CHAR_HEIGHT
CHAR_MODELINE charline_number,font2_addr,charmap2_addr
charline_number defl charline_number+1
endm
;; sync block:
;; size of bottom border [3 lines]
db 256-3,18,63,0,0,0,0,0,0,0,0,0,0,0,0,0
;; sync on [4 lines]
db 256-4,16,6,63,0,0,0,0,0,0,0,0,0,0,0,0
;; sync off at half line [1 line]
db 256-1,16,63,32,0,0,0,0,0,0,0,0,0,0,0,0
;; blank [4 lines]
db 256-4,18+VINT,6,63,0,0,0,0,0,0,0,0,0,0,0,0
;; size of top border [12 lines]
db 256-12,19,63,0,0,0,0,0,0,0,0,0,0,0,0,0
entab_data equ $
-
I can think only for cause of thel problem, the code always reset the LPT, please try to skip OR LPCLOCK LPLOAD part, only load LPL and LPH once. I never used or 80 , or C0 for LPH and i did not experienced this jumping.
-
I can think only for cause of thel problem, the code always reset the LPT, please try to skip OR LPCLOCK LPLOAD part, only load LPL and LPH once. I never used or 80 , or C0 for LPH and i did not experienced this jumping.
Thanks, that was the problem. Changed to the code below and the problem was solved.
ld a,LOW((LPT1_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
OUT (LPL),A
ld a,(lpt_nick_start_addr+1)
add a,HIGH((LPT1_CPU_ADDRESS-SCREEN_CPU_ADDRESS)/16)
or LPCLOCK+LPLOAD
OUT (LPH),a
Funny, because I was using code from one of enterprise docs - the "program to demonstrate simple use of the Nick chip" (from 84.1.17 ET1/1).
Now I need to modify all other "projects"...
-
Oh, this also fixes the problem in hattrick that I asked about earlier - the "how to properly switch between lpts so that I don't get the occassional screen 'jumps'"
From what I'm reading now (well better late then never, I guess) the code I used earlier made the switch instantenous and the fixed code waits with the change until the REPEAT signal in the last modeline.
-
Oh, this also fixes the problem in hattrick that I asked about earlier - the "how to properly switch between lpts so that I don't get the occassional screen 'jumps'"
From what I'm reading now (well better late then never, I guess) the code I used earlier made the switch instantenous and the fixed code waits with the change until the REPEAT signal in the last modeline.
Great :-) I remember that i read about the problem, just i did not know the problem then.
Yes, the code what you used, made an instant change, and the new waits until lpt reload bit is reached :-)
-
Now I need to modify all other "projects"...
This is a very small modification ;-)