News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_EgoTrip

Dumb Screen Question

Started by EgoTrip, 21:04, 09 February 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EgoTrip

Another question which is probably really obvious but I cant figure it out.


How do I set up a 256*256 (32*32 chars) screen in machine code, which is centered? Also, is it possible so the lines are not staggered for use in BASIC?

TFM

Do this:


;CRTC auf 64 Zeichen und 32 Zeilen setzen
;F, BC, DE, HL manipuliert
;CRTC Register 1, 2, 4, 5, 6 und 7 manipuliert
;
S64X32 LD HL,&2506:LD DE,&202A ;H = 37, L = 8, D = 32, E = 42
LD  BC,&BC01 ;Reg. 1 - Wert 32
OUT (C),C
INC B
OUT (C),D
DEC B     ;Reg. 2 - Wert 42
INC C
OUT (C),C
INC B
OUT (C),E
DEC B     ;Reg. 4 - Wert 37
LD  C,&04
OUT (C),C
INC B
OUT (C),H
DEC B     ;Reg. 5 - Wert 8
INC C
OUT (C),C
INC B
OUT (C),L
DEC B     ;Reg. 6 - Wert 32
INC C
OUT (C),C
INC B
OUT (C),D
DEC B     ;Reg. 7 - Wert 34
INC C
OUT (C),C
INC B
LD  D,&22
OUT (C),D
RET



Ok, you can do it a bit more easy without using register 5, but this is preset for pixel-wise scrolling routines... I leave it meanwhile.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

db6128

#2
; Set up the screen
ld hl,SCR_TBL
; CRTC
ld a,(hl)   ; number of pairs of register/value data
inc hl
ld b,&BC    ; I/O address to select register of CRTC
    CRTC_SET:
ld c,(hl)   ; Get number of register
inc hl
out (c),c   ; Select it
inc b       ; B = &BD = I/O address to write value to register
ld c,(hl)   ; Get data to write to this register
inc hl
out (c),c   ; Write it
dec b       ; back to &BC
dec a       ; Check whether we have output all the required pairs of data
jr nz,CRTC_SET
; Gate Array
ld a,(hl)   ; HL has been incremented to GA_TBL, so get number of bytes to write to GA
inc hl
ld b,&7F    ; I/O address of Gate Array
    GA_SET:
ld c,(hl)   ; Get data
inc hl
out (c),c   ; Write it
dec a       ; Check counter
jr nz,GA_SET

; [...]

    SCR_TBL:
; CRTC
db 6        ; pairs of data
db 1,32     ; columns, measured as MODE 1 characters (i.e. bytes/2)
db 2,42     ; H-sync pulse location, i.e. screen position
db 6,32     ; rows
db 7,34     ; V-sync pulse location
db 12,SCR_BASE    ; base = &4000
db 13,0     ; Reset the offset in case the screen had been scrolled prior to load
; Gate Array
db 13       ; number of values to OUTput
db &80+&C+0 ; Gate Array + select mode/ROMs + disable ROMs + mode 0
db 0,&54,1,&4C,2,&52,3,&55,4,&4A,16,&40    ; pens/ink
Quote from: Devilmarkus on 13:04, 27 February 12
Quote from: ukmarkh on 11:38, 27 February 12[The owner of one of the few existing cartridges of Chase HQ 2] mentioned to me that unless someone could find a way to guarantee the code wouldn't be duplicated to anyone else, he wouldn't be interested.
Did he also say things like "My treasureeeeee" and is he a little grey guy?

EgoTrip

Thanks for the replies.


TFM yours works but its staggered in BASIC. Is it possible to fix that, or not? No big deal if not, just wondering.


db yours doesn't work at all for me.

Sykobee (Briggsy)

I would guess that the BASIC editor, and also potentially BASIC keywords like LOCATE are not aware of the screen width, and assume it's 80 bytes wide.


There isn't really a way around this unless someone can hack the ROM extensively to make its routines aware of the screen layout.

db6128

#5
Quote from: EgoTrip on 22:56, 09 February 13db yours doesn't work at all for me.
Do you mean nothing happens at all?

I did leave the label SCR_BASE in there, which presumably doesn't exist in your project and therefore may be getting replaced by 0 or nonsense, so replace it with whatever you want: 0 for &0000, 1 for &4000, 2 for &8000, or 3 for &C000 (the default), remembering that 0 is unusable alongside the firmware and BASIC unless you offset it out of the way and 2 is unusable in all cases if you want to preserve the firmware.

But I can't seem to find any other problems. I don't have WinAPE here to test it, though. If I think of anything, I'll let you know.
Quote from: Devilmarkus on 13:04, 27 February 12
Quote from: ukmarkh on 11:38, 27 February 12[The owner of one of the few existing cartridges of Chase HQ 2] mentioned to me that unless someone could find a way to guarantee the code wouldn't be duplicated to anyone else, he wouldn't be interested.
Did he also say things like "My treasureeeeee" and is he a little grey guy?

EgoTrip

For now I am sticking with TFM's routine as it works perfectly. Thanks anyway though db6128.


However I do need further help, how do I set up a pallette split? I want the bottom 4 lines on the HUD (64 pixel rows) to be a different colour to the play area.

TFM

Quote from: EgoTrip on 22:56, 09 February 13
TFM yours works but its staggered in BASIC. Is it possible to fix that, or not? No big deal if not, just wondering.
Yes, because BASIC works with 80x25 instead of 64x32 characters.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: EgoTrip on 21:04, 09 February 13
Another question which is probably really obvious but I cant figure it out.


How do I set up a 256*256 (32*32 chars) screen in machine code, which is centered? Also, is it possible so the lines are not staggered for use in BASIC?
it will be staggered in BASIC. Only way to fix that is to patch BASIC which is not so easy a task.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Nich

Quote from: EgoTrip on 18:53, 10 February 13
However I do need further help, how do I set up a pallette split? I want the bottom 4 lines on the HUD (64 pixel rows) to be a different colour to the play area.
You may want to look at the source code for Area 51 - a Spectrum game that I converted to the CPC several years ago. You can download the game and source code from NVG.

The principle is that you need to set up an interrupt which is called 300 times a second (6 times per screen frame). You use a counter which is incremented each time the interrupt is called, and when the counter reaches 6, it is reset to 0. When the counter reaches a certain value, the inks are changed to the colours for the HUD, and when the counter equals 0, the inks are changed back to the colours for the main screen.

Powered by SMFPacks Menu Editor Mod