News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Fran123

screen split, help!

Started by Fran123, 11:37, 14 December 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fran123

Hello
I have wasted two weeks trying to get an split screen. I have a lot of examples and studied the code and read guides, but I did't get it.

I want 4 lines at top to show score and other information, and the other 21 lines for the game area.
For game I want to use double buffer and splitting the screen I save 2560 bytes.
Can anyone help me?
Thank you.



abalore

For debugging CRTC related stuff I use WinAPE. I open the Debug/Registers window, enable the "Row highlight" and "Int highlight" checkboxes, and then execute step-by-step.

Fran123

I did the same, but I didn't get anything  :-[

Ast

_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Arnaud

#4
Quote from: Fran123 on 11:37, 14 December 21
Hello
I have wasted two weeks trying to get an split screen. I have a lot of examples and studied the code and read guides, but I did't get it.

I want 4 lines at top to show score and other information, and the other 21 lines for the game area.
For game I want to use double buffer and splitting the screen I save 2560 bytes.
Can anyone help me?
Thank you.

Maybe you can put your code snippet here to see what is wrong ? I am also interesting to see how it can be done on interruption.

There is an interesting example here :
https://www.chibiakumas.com/z80/platform5.php#LessonP41


Fran123

Thank you, but I tried with a lot of combinations and when they didn't work I removed them.

Longshot

Hi Fran123,

I'm translating it into English (which takes a long time), but you can look at the following document (if you can translate from French), which should help you get it right.
http://logonsystem.fr/down/ACCC2-FR.pdf

You can also ask questions here for things you haven't understood.
;)
Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

Fran123

Quote from: Ast on 21:58, 14 December 21
You could try to read


https://amstradplus.forumforever.com/t319-Programmez-vos-ruptures-facilement.htm
And
https://amstradplus.forumforever.com/t550-Programmez-vos-Ruptures-encore-plus-facilement.htm


If you didn't succeed i will do it for you.


Three weeks later I stay at the same point. I read all the documents you posted but I didn't got it  :picard: :picard: :picard:
I wanted two screens, the first one with 4 lines, and the second one with 23.


I would be very grateful if you could help me.

Ast

Quote from: Fran123 on 12:39, 08 January 22

Three weeks later I stay at the same point. I read all the documents you posted but I didn't got it  :picard: :picard: :picard:
I wanted two screens, the first one with 4 lines, and the second one with 23.


I would be very grateful if you could help me.


Hi,


Here is my participation to your project. I really hope it will help you.




org #A000
run $
;
; Split Sample for FRAN123
; AsT/iMPACT Jan 2022.
;
di
ld hl,#c9fb ; kill int
ld (#38),hl
ei
;
wait ld b,#f5
vbl in a,(c)
rra
jr nc,vbl
;
ld hl,#077F
call set_crtc
;
ld b,0
djnz $
djnz $
;
ld hl,#0404-1 ; First split 4 lines
call set_crtc
;
ei
halt ; wait for some lines
ld b,12
l0 ds 60,0
djnz l0
;
ld hl,#0400+35-1 ; Second Split
call set_crtc
;
ld hl,#0700+35-4
call set_crtc
;
jp wait
;
; H=Reg | L=Value
;
set_crtc
ld b,#bc
out (c),h
inc b
out(c),l
ret
;


_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Arnaud

#9
Quote from: Ast on 13:25, 08 January 22Hi,

Here is my participation to your project. I really hope it will help you.

To be used in a game, the split screen routine shouldn't be done in interruption ?

Just wonder  ::)

lmimmfn

Quote from: Arnaud on 11:47, 09 January 22
To be used in a game, the split screen routine shouldn't be done in interruption ?

Just wonder  ::)
Interrupts can of course be used in games and were freqyently used, however on entering the interrupt push the registers onto the stack and pop them before exiting the interrupt, as it can be called anytime during the game code.


For code you dont want to be interrupted us di and ei, but timing is important as if you miss an interrupt everything will be messed up.
6128 for the win!!!

gurneyh

#11
Not so easy to make a simple split with this format (1 screen of 3 lines, and 1 screen of 21 lines)


However, here is a test under interruption (tested only under winape)


     org &4000
    run &4000
   
   di
   ld hl, &0721
   call set_crtc
   ei
   
di
   ld hl, &8000
   ld (hl), &FF
   ld de, &8001
   ld bc, &3FFF
   ldir




   ld b, &f5
w_no
    in a, (c)
    rra
    jr c, w_no
   
    ld b, &f5
w:   in a, (c)
    rra
    jr nc, w
   
    di
    ld a, &c3
    ld (&38), a
    ld hl, int_0
    ld (&39), hl
    ei
   
ld hl, &0054
    ld b, &7f
    out (c), h
    out (c), l
main_loop:




    jr main_loop
   
int_0:
di
    push hl
    push bc
    ld hl, &07ff
    call set_crtc
    ld hl, &1054
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
    pop hl
    ld hl, int_1
    ld (&39), hl
    ei
    ret   

int_1:
di
    push hl
    push bc
    ld b, 2
    call wait_line


    ; VCC = 1
    ld hl, &0402 ; reg 4 = 3 - 1
    call set_crtc

    ld hl, &0c30 ; set 2nd screen adr
    call set_crtc
   
    ld hl, &1044
    ld b, &7f
    out (c), h
    out (c), l
    ld b, 2*8
    call wait_line
    ld hl, &0400 + 36 -1 ; reg 4 = 36 - 1
    call set_crtc
    ld hl, &0700 + 36 - 6

    call set_crtc
    pop bc
    pop hl
    ld hl, int_2
    ld (&39), hl
    ei
    ret
   
int_2:
di
    push hl
push bc
    ld hl, &1055
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_3
    ld (&39), hl
     ei
    ret
   
int_3:
    di
    push hl
push bc
    ld hl, &105c
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_4
    ld (&39), hl
    ei
    ret
   
int_4:
di
    push hl
push bc
    ld hl, &1058
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_5
    ld (&39), hl
     ei
    ret

  int_5:
  di
    push hl
push hl
    ld hl, &105d
    ld b, &7f
    out (c), h
    out (c), l
    ld hl, &0c20 ; set first screen adr
    call set_crtc
    pop bc
pop hl
    ld hl, int_0
    ld (&39), hl
     ei
    ret




set_crtc:
   ld b,&bc
   out (c),h
   inc b
   out(c),l
   ret




wait_line:
wloop:   ds 60
   djnz wloop
ret



edit:the code was in rasm format and not winape :( 
... and fix timing for crtc 1

Fran123

Hello


First at all, thank you very much for your help.


I had to do some modifications to get the 4+23 lines, but now I don't get set the screen in the middle.
How I can solve that?


That's I got:





And here's the code:



org &4000
run &4000
   
macro nexti dire
    ld hl, dire
    ld (&39), hl
endm


   di
   ld hl, &0721
   call set_crtc
   ei
   
di
   ld hl, &8000
   ld (hl), &FF
   ld de, &8001
   ld bc, &3FFF
   ldir




;;----------------
ld b, &f5
w_no
in a, (c) :  rra :  jr c, w_no : ld b, &f5
w:   
in a, (c) : rra
jr nc, w
   
di : ld a, &c3 : ld (&38), a : nexti int_0 : ei
;;-------------


main_loop:
    jr main_loop


   
int_0:
di
ld hl, &07ff
call set_crtc
ld hl, &0600 + 4 ; i want 4 lines in first screen
call set_crtc
nexti int_1 ; next int. function
ei
ret   



int_1:
di
;ld a, 4
;call wait_lines


; VCC = 1
ld hl, &0400 + 4 -1 ; reg 4 = 3 - 1; one line greater
call set_crtc

ld hl, &0c30 ; set 2nd screen adr
call set_crtc
   
ld a, 8
call wait_lines ; it must be separation between the two R4 settings


; for next screen
ld hl, &0400 + 35 -1 ; reg 4 = 36 - 1
call set_crtc
ld hl, &0700 + 37 - 6
call set_crtc
ld hl, &0600 + 23 ; lines displayed
call set_crtc


nexti int_2
ei
ret
 

int_2:
di
nexti int_3 : ei : ret
   


int_3:
di : nexti int_4 : ei : ret
   


int_4:
di : nexti int_5 : ei : ret



int_5:
di
; next screen
ld hl, &0c20 ; set first screen adr
call set_crtc
nexti int_0
ei
ret




set_crtc:
   ld b,&bc
   out (c),h
   inc b
   out(c),l
   ret




;; in: A - number of lines
wait_lines:
ld b, 18 ;7
wloop
djnz wloop ;17*13+8 ticks
dec a
jr nz, wait_lines
ret



Thank you

gurneyh

#13
Sorry, I misread your first post


So here is a 4-line screen, followed by a 23-line screen



     
     org &4000
    run &4000
   
   di
   ld hl, &0721
   call set_crtc
   ei
   
di
   ld hl, &8000
   ld (hl), &FF
   ld de, &8001
   ld bc, &3FFF
   ldir




   ld hl, #0600 + 23
   call set_crtc


   ld b, &f5
w_no
    in a, (c)
    rra
    jr c, w_no
   
    ld b, &f5
w:   in a, (c)
    rra
    jr nc, w
   
    di
    ld a, &c3
    ld (&38), a
    ld hl, int_0
    ld (&39), hl
    ei
   
ld hl, &0054
    ld b, &7f
    out (c), h
    out (c), l
main_loop:








    jr main_loop
   
int_0:
di
    push hl
    push bc
    ld hl, &07ff
    call set_crtc
    ld hl, &1054
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
    pop hl
    ld hl, int_1
    ld (&39), hl
    ei
    ret   

int_1:
di
    push hl
    push bc
    ld b, 2
    call wait_line




    ; VCC = 1
    ld hl, &0400 + 4 - 1 ; reg 4 = 4 - 1
    call set_crtc
   
    ld hl, &0c30 ; set 2nd screen adr
    call set_crtc
   
    ld hl, &1044
    ld b, &7f
    out (c), h
    out (c), l
    ld b, 4*8
    call wait_line
    ld hl, &0400 + 35 -1 ; reg 4 = 36 - 1
    call set_crtc
    ld hl, &0700 + 35 - 6

    call set_crtc
    pop bc
    pop hl
    ld hl, int_2
    ld (&39), hl
    ei
    ret
   
int_2:
di
    push hl
push bc
    ld hl, &1055
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_3
    ld (&39), hl
     ei
    ret
   
int_3:
    di
    push hl
push bc
    ld hl, &105c
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_4
    ld (&39), hl
    ei
    ret
   
int_4:
di
    push hl
push bc
    ld hl, &1058
    ld b, &7f
    out (c), h
    out (c), l
    pop bc
pop hl
    ld hl, int_5
    ld (&39), hl
     ei
    ret

  int_5:
  di
    push hl
push hl
    ld hl, &105d
    ld b, &7f
    out (c), h
    out (c), l
    ld hl, &0c20 ; set first screen adr
    call set_crtc
    pop bc
pop hl
    ld hl, int_0
    ld (&39), hl
     ei
    ret








set_crtc:
   ld b,&bc
   out (c),h
   inc b
   out(c),l
   ret








wait_line:
wloop:   ds 60
   djnz wloopret


Fran123

Wow


I thought I had to use R6.


A couple questions?


Is it possible not using a wait_line using instead different values for R7, or is there a way to reduce the number of lines for wait_line?  (I tried that and I didn't get good result, of course  :picard: )


Is it possible to lower a (character) line the splitted screens?  (again  :picard: )


Thank you very much

gurneyh


You can effectively reduce the wait, by moving the start of the screen down.
However, you will not be able to eliminate the wait completely. Also, it may be worthwhile to place some useful code rather than waiting foolishly. For example, a keyboard reading, a music player?

andycadley

You can entirely eliminate the wait if you use the GX hardware, but otherwise your best bet is to find something useful to do during the wait time (though this can be tricky since you want constant time code).

Curlypaul

Quote from: Arnaud on 11:47, 09 January 22
To be used in a game, the split screen routine shouldn't be done in interruption ?

Just wonder  ::)


I'm assuming you really mean the use of the halt, and similar to the answers directly above about about the wait line, ideally you'd find a useful function that's roughly the same number of cycles as you end up waiting for at the halt.

This is the really difficult part, once you've got your complex screen working, you've somehow got to pepper the rest of your program into the gaps without it getting mind bogglingly complex. Or.. buy a plus.

Nworc

You really won't loose too much time if you are using the second interrupt and wait until the screen starts - this will cost you approx. 10 rasters out of 312, not really worth to code something timing accurate instead of waiting, until you have a timing accurate playback routine which would fit in.

That guide which was mentioned above (https://www.chibiakumas.com/z80/platform5.php#LessonP41) is a great tutor to explain these splits! It's explaining even more than you need to know for your simple task.

Curlypaul

True, in this particular set up there's probably not much point bothering.

Personally I've been playing with midscreen splits which has this problem, but probably allows for easier double buffering than an overscaned screen. Probably anyway, I need to try it, and if true, the choice depends what you are drawing.

Powered by SMFPacks Menu Editor Mod