Author Topic: Interlace Demo - Maybe 464 Only?  (Read 2888 times)

0 Members and 2 Guests are viewing this topic.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1159
  • Likes Given: 1931
Interlace Demo - Maybe 464 Only?
« on: 12:25, 04 August 10 »
I think I've talked and maybe posted this Interesting Demo before, but not on this forum!  :-\  It was a Type-in in AA46 (July 1989) and is described as a program which effectively doubles the resolution of the Y Axis  - so instead of having 200 for the usual Y axis you've got 400!
 
I'm guessing that there maybe some 464 instructions in this program which I think is the &BC06 instruction which is used to interchange the screen. I think on a 664/6128 it's possible to use &BC07(?). What I'm interested in finding out is if this program could me made any faster, as it is the program works well if you have a Green Screen on a Real CPC.  I'm guessing that even if some find tweaking were done to make it run faster it still wouldn't be fast enough to produce simular results on a Colour Monitor. Perhaps on an Emulator running outside of Realtime mode would be the only means of having it working properly?
 
The other thing I noticed is it's Text Based (arrugh), I'm guessing making it Graphically based would be asking for trouble. Perhaps worthwhile making a program to run outside Realtime Mode using Text Graphics!  :)
 
Code: [Select]
70 ' INTERLACE DEMO
80 ' Amstrad Action ** '89
90 ' By John Valentine
100 GOSUB 550:MODE 2
110 SYMBOL AFTER 0
120 CALL &BC06,&C0:CLS:CALL &BC06,&40:CLS
130 CALL &BD19:EVERY 1 GOSUB 140:GOTO 200
140 IF f=0 THEN OUT &BC00,5:OUT &BD00,5:CALL &BC06,&C0:f=1 ELSE OUT &BC00,5:OUT &BD00,4:CALL &BC06,&40:f=0
150 RETURN
200 FOR row=0 TO 7:FOR col=0 TO 31
210 m$=CHR$(row*32+col):x=col*2+7:y=row+3
220 GOSUB 510:NEXT:NEXT
230 FOR a=1 TO 25:m$=CHR$(246):x=0:GOSUB 510
240 m$=CHR$(247):x=79:GOSUB 510:NEXT
250 x=15:y=20:m$="Interlace demo - "
260 m$=m$+"Let your CPC imitate an Amiga!"
270 GOSUB 510
280 GOTO 280
500 ' TEXT ROUTINE (x,y,m$)
510 FOR n=1 TO LEN(m$)
520 CALL &8000,x,y,ASC(MID$(m$,n,1))
530 x=x+1:IF x>79 THEN x=0:y=y+1:IF y=25 THEN y=0
540 NEXT:RETURN
550 FOR n=1 TO 14:t=0:FOR a=1 TO 8
560 READ N$:p=VAL("&"+n$)
570 POKE &8000+add,p:t=t+p:add=add+1:NEXT
580 READ tt:IF tt<>t THEN PRINT"ERROR IN LINE";1000+lin*10:LIST 1000-
590 lin=lin+1:NEXT
600 RETURN
1000 DATA DD,66,04,DD,6E,02,CD,1A,891
1010 DATA BC,11,00,08,19,7C,E6,3F,655
1020 DATA F6,C0,67,22,67,80,11,00,823
1030 DATA 10,19,7C,E6,3F,F6,40,67,871
1040 DATA 22,6B,80,DD,7E,00,CD,A5,986
1050 DATA BB,2B,06,00,23,7E,ED,5B,725
1060 DATA 67,80,12,23,7E,ED,5B,6B,845
1070 DATA 80,12,E5,CD,46,80,E1,04,1007
1080 DATA 78,FE,04,20,E7,C9,2A,6B,991
1090 DATA 80,11,00,08,19,7C,E6,3F,595
1100 DATA F6,40,67,22,6B,80,2A,67,827
1110 DATA 80,11,00,08,19,7C,E6,3F,595
1120 DATA F6,C0,67,22,67,80,C9,E4,1235
1130 DATA E9,00,00,E4,79,00,00,20,614

 
« Last Edit: 08:49, 05 August 10 by CP/M User »
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2280
  • Likes Given: 3478
Re: Interlace Demo - Maybe 464 Only?
« Reply #1 on: 12:40, 04 August 10 »
I think I've talked and maybe posted this Interesting Demo before, but not on this forum!  :-\  It was a Type-in in AA46 (July 1989) and is described as a program which effectively doubles the resolution of the Y Axis  - so instead of having 200 for the usual Y axis you've got 400!
 
I'm guessing that there maybe some 464 instructions in this program which I think is the &BC06 instruction which is used to interchange the screen. I think on a 664/6128 it's possible to use &BC07(?). What I'm interested in finding out is if this program could me made any faster, as it is the program works well if you have a Green Screen on a Real CPC.  I'm guessing that even if some find tweaking were done to make it run faster it still wouldn't be fast enough to produce simular results on a Colour Monitor. Perhaps on an Emulator running outside of Realtime mode would be the only means of having it working properly?
 
The other thing I noticed is it's Text Based (arrugh), I'm guessing making it Graphically based would be asking for trouble. Perhaps worthwhile making a program to run outside Realtime Mode using Text Graphics!  :)
 
Code: [Select]
70 ' INTERLACE DEMO
80 ' Amstrad Action ** '89
90 ' By John Valentine
100 GOSUB 550:MODE 2
110 SYMBOL AFTER 0
120 CALL &BC06,&C0:CLS:CALL &BC06,&40:CLS
130 CALL &BD19:EVERY 1 GOSUB 140:GOTO 200
140 IF f=0 THEN OUT &BC00,5:OUT &BD00,5:CALL &BC06,&C0:f=1 ELSE OUT &BC00,5:OUT &BD00,4:CALL &BC06,&40:f=0
150 RETURN
200 FOR row=0 TO 7:FOR col=0 TO 31
210 m$=CHR$(row*32+col):x=col*2+7:y=row+3
220 GOSUB 510:NEXT:NEXT
230 FOR a=1 TO 25:m$=CHR$(246):x=0:GOSUB 510
240 m$=CHR$(247):x=79:GOSUB 510:NEXT
250 x=15:y=20:m$=Interlace demo - "
260 m$=m$+"Let your CPC imitate an Amiga!"
270 GOSUB 510
280 GOTO 280
500 ' TEXT ROUTINE (x,y,m$)
510 FOR n=1 TO LEN(m$)
520 CALL &8000,x,y,ASC(MID$(m$,n,1))
530 x=x+1:IF x>79 THEN x=0:y=y+1:IF y=25 THEN y=0
540 NEXT:RETURN
550 FOR n=1 TO 14:t=0:FOR a=1 TO 8
560 READ N$:p=VAL("&"+n$)
570 POKE &8000+add,p:t=t+p:add=add+1:NEXT
580 READ tt:IF tt<>t THEN PRINT"ERROR IN LINE";1000+lin*10:LIST 1000-
590 lin=lin+1:NEXT
600 RETURN
1000 DATA DD,66,04,DD,6E,02,CD,1A,891
1010 DATA BC,11,00,08,19,7C,E6,3F,655
1020 DATA F6,C0,67,22,67,80,11,00,823
1030 DATA 10,19,7C,E6,3F,F6,40,67,871
1040 DATA 22,6B,80,DD,7E,00,CD,A5,986
1050 DATA BB,2B,06,00,23,7E,ED,5B,725
1060 DATA 67,80,12,23,7E,ED,5B,6B,845
1070 DATA 80,12,E5,CD,46,80,E1,04,1007
1080 DATA 78,FE,04,20,E7,C9,2A,6B,991
1090 DATA 80,11,00,08,19,7C,E6,3F,595
1100 DATA F6,40,67,22,6B,80,2A,67,827
1110 DATA 80,11,00,08,19,7C,E6,3F,595
1120 DATA F6,C0,67,22,67,80,C9,E4,1235
1130 DATA E9,00,00,E4,79,00,00,20,614
It uses CRTC register 5 (vertical adjust), and then every 50th of a second it switches the screen base. One screen at &4000-&7fff and the other at &c000-&ffff.

This will work fine on all CPCs.

Another alternative method which I used before is to use crtc register 8 and set it to 1.
Both are valid and effectively work the same.

Can it be made faster? Yes.

Code: [Select]
org &8000

r5swap equ 5 XOR 4
baseswap equ &30 XOR &10


di
ld hl,&c9fb
ld (&0038),hl
ei

.l1 ld b,&f5
.l2 in a,(c)
rra
jr nc,l2

ld bc,&bc05
out (c),c
inc b
ld a,(r5)
out (c),a

ld bc,&bc0c
out (c),c
inc b
ld a,(base)
out (c),a

halt

halt

halt

ld a,(r5)
xor r5swap
ld (r5),a

ld a,(base)
xor baseswap
ld (base),a

jp l1

.r5:
defb 5

.base
defb &30

What would be more interesting is if basic or firmware could be altered to use this automatically.
(scr next line would probably need to be changed ;) )

I have another type-in from Amstrad Computer User that turned the cpc's screen into a BBC like screen with 32 lines.
I'll dig it out and get it uploaded for others to look at.

(call &bc06 is likely to be firmware function SCR SET BASE, call &bd19 is firmware function MC WAIT FLYBACK)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1017
  • Likes Given: 926
Re: Interlace Demo - Maybe 464 Only?
« Reply #2 on: 13:32, 04 August 10 »
Nice effect.
I use the same effect for flipscreens.

Result of the basic program, with de-interlace filter and scanlines:
(It has a " missing in line 250)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1159
  • Likes Given: 1931
Re: Interlace Demo - Maybe 464 Only?
« Reply #3 on: 09:08, 05 August 10 »
Devilmarkus wrote:

Nice effect.
I use the same effect for flipscreens.

Result of the basic program, with de-interlace filter and scanlines:
(It has a " missing in line 250)


Yes unfortunately that's my fault for not checking it carefully. Naturally I checked everything else so nobodies monitors would blowup. I've corrected the original post!  ;D
 
arnoldemu wrote:
 
Can it be made faster? Yes.

Code: [Select]
org &8000

r5swap equ 5 XOR 4
baseswap equ &30 XOR &10


di
ld hl,&c9fb
ld (&0038),hl
ei

.l1 ld b,&f5
.l2 in a,(c)
rra
jr nc,l2

ld bc,&bc05
out (c),c
inc b
ld a,(r5)
out (c),a

ld bc,&bc0c
out (c),c
inc b
ld a,(base)
out (c),a

halt

halt

halt

ld a,(r5)
xor r5swap
ld (r5),a

ld a,(base)
xor baseswap
ld (base),a

jp l1

.r5:
defb 5

.base
defb &30

Interesting!  :)  Though I'm not quite sure how this routine works!  :-[
« Last Edit: 09:15, 05 August 10 by CP/M User »
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2280
  • Likes Given: 3478
Re: Interlace Demo - Maybe 464 Only?
« Reply #4 on: 11:53, 05 August 10 »
arnoldemu wrote:
 
Can it be made faster? Yes.

Code: [Select]
org &8000

;; crtc register 5 adds a user defined number of scanlines to the end of the current crtc "frame".
;; by choosing two numbers that are different by 1, the screen is moved up and down by a scanline
;; each frame. At the same time we change screens. &c000 has even lines, &4000 has odd lines of our 400 tall screen.
;; by the way we use register 5 and exchange screens we can get the interlace effect.
;; the effect is also dependant on the monitor itself and the persistance of it's phosphors. if the persistence is not good
;; the screen will flicker, if it is good, the screen will have less flicker.

;; this is the value to exchange between 5 and 4
r5swap equ 5 XOR 4

;; this is the value to exchange between &30 and &10. &30 corresponds to screen @ &c000 and &10 corresponds to screen @ &4000.
baseswap equ &30 XOR &10


;; install a "null" interrupt handler. We are only really interested in stopping the firmware from interrupting.
;; if it did, it would slow us down.
di
ld hl,&c9fb   ;; c9 = ret, fb = ei. when written to ram this becomes ei:ret.
ld (&0038),hl
ei

;; wait for start of vsync
.l1 ld b,&f5
.l2 in a,(c)
rra
jr nc,l2

;; write data to crtc register 5
ld bc,&bc05
out (c),c
inc b
ld a,(r5)
out (c),a

;; write data to crtc register 12 (screen start, high byte)
;; leave low byte because we are not scrolling.
ld bc,&bc0c
out (c),c
inc b
ld a,(base)
out (c),a

;; these wait for interrupt. so interrupts must be active.
;; they are here mainly to wait long enough for vsync to finish so
;; that the wait for vsync start works correctly
halt

halt

halt

;; swap value for crtc register 5
ld a,(r5)
xor r5swap
ld (r5),a

;; swap value for crtc register 12
ld a,(base)
xor baseswap
ld (base),a

jp l1

;; default value for crtc register 5
.r5:
defb 5

;; default value for crtc register 12
.base
defb &30

Interesting!  :)  Though I'm not quite sure how this routine works!  :-[
I edited it for you ;)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1159
  • Likes Given: 1931
Re: Interlace Demo - Maybe 464 Only?
« Reply #5 on: 23:41, 28 January 11 »
I was just trialing out your Fake Interlace from your website, though when I came to testing it out on some screens, it looked as if it was alternative between the two. I modified the code to this:
 
Code: [Select]
; Source code to produce fake interlace
;
; This code will display 640x400 image.
;
; The graphics are stored so that the image at &c000 has all even
; lines and the image at &4000 has all odd lines of the final image.
;
;; VSYNC 1: reg 5 = 0, display &C000
;; VSYNC 2: reg 5 = 1, display &4000
;
; We can modify this code to work with the firmware, but I have
; written it without because it is easier at the moment.
;
; If we have different colours for each screen then we can mix colours
; to produce new ones.
;
; Extra colours can be produced by flashing two existing colours rapidly.
;
; A better Interlace effect may be produced without the reg 5 trick.
 org &8000
;; ld a,1
;; call &bc0e   ; mode 2
 xor a
 ld bc,&0000
 call &bc32   ; background = black
 ld a,1
 ld bc,&1a1a
 call &bc32   ; foreground = white
     ; we now have a black and white
     ; standard mode 2 screen
.main_loop
 ld b,&f5
.m1 in a,(c)
 rra
 jr nc,m1
 ; this should be executed every VSYNC
 ld e,0    ; reg 5 offset = 0
 ld hl,&3000   ; screen in range &c000-&ffff
.frame ld a,0    ; frame we are displaying (0 or &ff)
 xor &ff
 ld (frame+1),a
 or a
 jr z,frame_0
 ld e,1
 ld hl,&1000
.frame_0
 ; set screen vertical shift
 ld bc,&bc05
 out (c),c
 inc b
 ld a,e
 out (c),a
 ; set screen address
 
 ld bc,&bc0c
 out (c),c
 ld a,h
 inc b
 out (c),a
 ld bc,&bc0d
 out (c),c
 ld a,l
 inc b
 out (c),a

 halt
 halt
 halt
 halt
 halt
 halt
 jp main_loop

And just loaded two standard CPC screens. Though I'm guessing this kind of routine is strictly for the real machine rather than the emulator.  :-[
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3