News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_SRS

Sin Wave ...

Started by SRS, 21:06, 04 February 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SRS

Found this on a old disc of mine.

Can't remember who wrote it (not me, I guess), but it is nice Demo Effect

1000 MODE 2:DEG:d=&7E00:FOR a=0 TO 359 STEP 2:y=COS(a)*95+95:PLOT a,y*2+18:POKE d,y:d=d+1:NEXT:POKE d,&FF:m=&8000:FOR d=0 TO 1:READ d$:FOR u=1 TO LEN(d$)/2:POKE m,VAL("&"+MID$(d$,(u-1)*2+1,2)):m=m+1:NEXT u,d
1010 CLS:CALL &8000
1020 DATA f32a3800229a8021fbc9223800fb21004206c836542310fbcd19bd76dd21a0803e10f5dd6e00dd6601237efeffc2338021007edd7500dd74015e164221c080010900edb0dd23dd23f13d20d676f3219f002b7cb5c251802100423ec801107f16005e23ed49ed59ed51ed590000060810fe3dc25c80dd21a080
1030 DATA 3e10dd6e00dd66015e164221c980010900edb0dd23dd233d20e8cd09bbd21880210000223800c9007e037e067e097e0c7e0f7e127e157e187e1b7e1e7e217e247e277e2a7e2d7e5c4c4e4a4b53575544545454545454545454


[attach=2]

EgoTrip

Cool demo.

Line 1020 is too long, so delete the last 1 then add 10 to the beginning of the next line.

SRS


Gryzor

Now that's impressive!!

ZbyniuR

It had to be in some magazine, because I had it once years ago. :)
In STARS, TREK is better than WARS.

EgoTrip

Can someone disassemble and comment the code so I can see how it works please?

||C|-|E||

It is actually very cool!  :) Sadly, I do not understand the code  :picard:

MaV

#7
I didn't dwell too long on it, but here's a first disassembly with a couple of comments:

; CPC/Z80 specific constants
.RST38              equ #0038
.EIRET              equ #C9FB
.MC_WAIT_FLYBACK    equ #BD19
.KM_READ_CHAR       equ #BB09
.NO_HORIZ_LINES     equ 200
.GA_PORT_SEL_BORDER equ #7F10

; Gate Array colour values
.GA_COL_BLUE          equ #44
.GA_COL_BRIGHT_YELLOW equ #4a
.GA_COL_BRIGHT_WHITE  equ #4b
.GA_COL_BRIGHT_RED    equ #4c
.GA_COL_ORANGE        equ #4e
.GA_COL_BRIGHT_CYAN   equ #53
.GA_COL_BLACK         equ #54
.GA_COL_BRIGHT_BLUE   equ #55
.GA_COL_SKY_BLUE      equ #57
.GA_COL_RED           equ #5c

; Program specific constants
.COPPER_START               equ #8000
.COSTAB                     equ #8100 ; lower byte must be zero!
.END_OF_COSTAB              equ #FF
.Horiz_Line_Cols_Table      equ #8200 ; 200 bytes of colour values for each horizontal line on screen
                                      ; lower byte must be zero!
.Horiz_Line_Cols_High_Table equ #82   ; high byte of Horiz_Line_Cols_Table
.Num_Visible_Bars           equ #10
.Length_Copper_Tables       equ #0009
.Long_Wait                  equ #009f
.Short_Wait                 equ #08

org COPPER_START
di
ld hl, (RST38)
ld (SaveInterrupt), hl
ld hl, EIRET                 ; insert EI+RET as interrupt handler
ld (RST38), hl
ei
ld hl, Horiz_Line_Cols_Table
ld b, NO_HORIZ_LINES

.FillBlackCol
ld (hl), GA_COL_BLACK
inc hl
djnz FillBlackCol

.Main_Loop
call MC_WAIT_FLYBACK
halt

ld ix, CosTable_Offsets
ld a, Num_Visible_Bars

.CreateBars
push af
ld l, (ix + #00)
ld h, (ix + #01)
inc hl
ld a, (hl)
cp END_OF_COSTAB
jp nz, GetOverIt

ld hl, COSTAB

.GetOverIt
ld (ix + #00), l
ld (ix + #01), h
ld e, (hl)
ld d, Horiz_Line_Cols_High_Table
ld hl, CopperBarColTable
ld bc, Length_Copper_Tables
ldir
inc ix
inc ix
pop af
dec a
jr nz, CreateBars

halt
di
ld hl, Long_Wait
.WaitABitLonger
dec hl
ld a, h
or l
jp nz, WaitABitLonger


ld hl, Horiz_Line_Cols_Table
ld a, NO_HORIZ_LINES

.CopperBars2Screen
ld bc, GA_PORT_SEL_BORDER
ld d, #00
ld e, (hl)
inc hl
out (c), c ; set border / out &7F00, &10
out (c), e ; with value / out &7F00, value_from_table
out (c), d ; set colour @ pen 0 / out &7F00, &00
out (c), e ; with value / out &7F00, value_from_table
nop
nop

ld b, Short_Wait
.WaitAMoment
djnz WaitAMoment

dec a
jp nz, CopperBars2Screen


ld ix, CosTable_Offsets
ld a, Num_Visible_Bars
.CreateBlackBars
ld l, (ix + #00)
ld h, (ix + #01)
ld e, (hl)
ld d, Horiz_Line_Cols_High_Table
ld hl, CopperBarBlackTable
ld bc, Length_Copper_Tables
ldir
inc ix
inc ix
dec a
jr nz, CreateBlackBars
call KM_READ_CHAR  ; loop until key is pressed
jp nc, Main_Loop

.SaveInterrupt equ $+1
ld hl, #41c3        ; dummy value?
ld (RST38), hl      ; restore interrupt
ret

.CosTable_Offsets
dw COSTAB + #29 ; COS(82)
dw COSTAB + #2c ; COS(88)
dw COSTAB + #2f ; COS(94)
dw COSTAB + #32 ; COS(100)
dw COSTAB + #35 ; COS(106)
dw COSTAB + #38 ; COS(112)
dw COSTAB + #3b ; COS(118)
dw COSTAB + #3e ; COS(124)
dw COSTAB + #41 ; COS(130)
dw COSTAB + #44 ; COS(136)
dw COSTAB + #47 ; COS(142)
dw COSTAB + #4a ; COS(148)
dw COSTAB + #4d ; COS(154)
dw COSTAB + #50 ; COS(160)
dw COSTAB + #53 ; COS(166)
dw COSTAB + #56 ; COS(172)

.CopperBarColTable
db GA_COL_RED
db GA_COL_BRIGHT_RED
db GA_COL_ORANGE
db GA_COL_BRIGHT_YELLOW
db GA_COL_BRIGHT_WHITE
db GA_COL_BRIGHT_CYAN
db GA_COL_SKY_BLUE
db GA_COL_BRIGHT_BLUE
db GA_COL_BLUE

.CopperBarBlackTable
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK
db GA_COL_BLACK

org COSTAB
db #be, #be, #be, #bd, #bd, #bd, #bc, #bb
db #ba, #b9, #b8, #b7, #b6, #b4, #b3, #b1
db #b0, #ae, #ac, #aa, #a8, #a6, #a3, #a1
db #9f, #9c, #99, #97, #94, #91, #8e, #8c
db #89, #86, #83, #7f, #7c, #79, #76, #73
db #6f, #6c, #69, #66, #62, #5f, #5c, #58
db #55, #52, #4f, #4b, #48, #45, #42, #3f
db #3b, #38, #35, #32, #2f, #2d, #2a, #27
db #25, #22, #1f, #1d, #1b, #18, #16, #14
db #12, #10, #0e, #0d, #0b, #0a, #08, #07
db #06, #05, #04, #03, #02, #01, #01, #01
db #00, #00, #00, #00, #00, #01, #01, #01
db #02, #03, #04, #05, #06, #07, #08, #0a
db #0b, #0d, #0e, #10, #12, #14, #16, #18
db #1b, #1d, #1f, #22, #25, #27, #2a, #2d
db #30, #32, #35, #38, #3b, #3f, #42, #45
db #48, #4b, #4f, #52, #55, #58, #5c, #5f
db #62, #66, #69, #6c, #6f, #73, #76, #79
db #7c, #7f, #83, #86, #89, #8c, #8f, #91
db #94, #97, #99, #9c, #9f, #a1, #a3, #a6
db #a8, #aa, #ac, #ae, #b0, #b1, #b3, #b4
db #b6, #b7, #b8, #b9, #ba, #bb, #bc, #bd
db #bd, #bd, #be, #be, END_OF_COSTAB

; the values of COSTAB are
; originally from BASIC:
; 10 DEG
; 20 d=&7E00
; 30 FOR a=0 TO 359 STEP 2
; 40 y=COS(a)*95+95
; 50 PLOT a,y*2+18
; 60 POKE d,y
; 70 d=d+1
; 80 NEXT
; 90 POKE d,&FF

Apparently, the magic is all in the tables. That'll be a bit difficult to comprehend.

CosTable contains the poked values of the BASIC program.

NotherTable can be set anywhere in RAM, CosTable however needs to be at #7E00 to function properly, Tab1's values are related to this address.

Update: I tweaked Tab1 to show the relationsip of it to the Cosinus-Table. The values of CosTable can now be changed from #7E00 to any other place provided the lower byte is zero.

Next Update: fully documented
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

MaV

I updated my original post. Everything should be clear now from reading the sources.
Black Mesa Transit Announcement System:
"Work safe, work smart. Your future depends on it."

Powered by SMFPacks Menu Editor Mod