Author Topic: Dumb Screen Question  (Read 2644 times)

0 Members and 1 Guest are viewing this topic.

Offline EgoTrip

  • 6128 Plus
  • ******
  • Posts: 1.058
  • Country: gl
    • http://egochip.blogspot.co.uk/
  • Liked: 704
  • Likes Given: 304
Dumb Screen Question
« on: 22: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?
EgoTrip's Stuff
EgoTrip's Stuff

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1985
  • Likes Given: 4650
Re: Dumb Screen Question
« Reply #1 on: 23:10, 09 February 13 »
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

Offline db6128

  • 464 Plus
  • *****
  • Posts: 316
  • Country: gb
  • We don’t speak 8080 in this house.
  • Liked: 72
  • Likes Given: 44
Re: Dumb Screen Question
« Reply #2 on: 23:18, 09 February 13 »
Code: [Select]
; 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
« Last Edit: 23:32, 09 February 13 by db6128 »
[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?

Offline EgoTrip

  • 6128 Plus
  • ******
  • Posts: 1.058
  • Country: gl
    • http://egochip.blogspot.co.uk/
  • Liked: 704
  • Likes Given: 304
Re: Dumb Screen Question
« Reply #3 on: 23:56, 09 February 13 »
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.
EgoTrip's Stuff
EgoTrip's Stuff

Offline Sykobee (Briggsy)

  • 6128 Plus
  • ******
  • Posts: 837
  • Country: gb
  • Liked: 314
  • Likes Given: 499
Re: Dumb Screen Question
« Reply #4 on: 00:35, 10 February 13 »
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.

Offline db6128

  • 464 Plus
  • *****
  • Posts: 316
  • Country: gb
  • We don’t speak 8080 in this house.
  • Liked: 72
  • Likes Given: 44
Re: Dumb Screen Question
« Reply #5 on: 01:24, 10 February 13 »
db 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.
« Last Edit: 01:30, 10 February 13 by db6128 »
[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?

Offline EgoTrip

  • 6128 Plus
  • ******
  • Posts: 1.058
  • Country: gl
    • http://egochip.blogspot.co.uk/
  • Liked: 704
  • Likes Given: 304
Re: Dumb Screen Question
« Reply #6 on: 19:53, 10 February 13 »
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.
EgoTrip's Stuff
EgoTrip's Stuff

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1985
  • Likes Given: 4650
Re: Dumb Screen Question
« Reply #7 on: 20:10, 10 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

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2280
  • Likes Given: 3478
Re: Dumb Screen Question
« Reply #8 on: 11:33, 11 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

Offline Nich

  • Supporter
  • 6128 Plus
  • *
  • Posts: 790
  • Country: gb
  • CPC Game Reviews webmaster
    • CPC Game Reviews
  • Liked: 713
  • Likes Given: 846
Re: Dumb Screen Question
« Reply #9 on: 23:11, 13 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.