Set Buffer 50 ' ----------------------------------------------------------------------- ' Simple Amos 256 COLOUR screen ' code by Kevin Picone ' Last Updated - 23, AUG, 1997 ' (c) Copyright 1997, Underware Design, All Rights Reseved ' ----------------------------------------------------------------------- ' PLEASE NOTE: IF THE AGA SCREEN DOES N'T APPEAR JUST KEEP PRESSING ' SPACE FOR A FEW SECONDS, UNTIL THE PROGRAM QUITS OUT. ' AND THEN TRY AND RUN IT AGAIN.... ' PLEASE NOTE: DON'T CTRL-C OUT OF THIS UNLESS YOUR USED TO CODING ' CUSTOM COPPER SCREENS IN AMOS. ' --------------------------------------------------------------------- ' >> INIT DEMO << ' --------------------------------------------------------------------- Rem On Error Proc _CLEANUP ' init TWO (4 bitplane) screens Screen Open 1,640,256,16,Hires : Curs Off : Flash Off : Cls 0 : Hide On Screen Open 0,640,256,16,Hires : Curs Off : Flash Off : Cls 0 : Hide On ' Load our test image Auto View Off Load Iff "testpic.iff",2 Curs Off : Flash Off : Screen Hide : Screen To Back Auto View On ' find the actual addresses (locations) of each bitplane in chip memory Dim BITPLANES(8) P=0 For I=0 To 3 Screen 0 : BITPLANES(P)=Logbase(I) Screen 1 : BITPLANES(P+4)=Logbase(I) Inc P Next I ' Define an array to hold our 256 colour palette values Dim PALCOLOUR(256) Gosub GT_256COL_PALETTE ' Define an array for one of the simple demo part ' This code, init's each objects random position, and random X & Y ' speed. OBJECTS=100 Dim OBJ(OBJECTS,5) For LP=0 To OBJECTS-1 X=(Rnd(480)+80)*$100 Y=(Rnd(160)+48)*$100 XS=(Rnd(256*8))-(256*4) YS=(Rnd(256*4))-(256*2) C=(Rnd(16)) OBJ(LP,0)=X OBJ(LP,1)=Y OBJ(LP,2)=XS OBJ(LP,3)=YS OBJ(LP,4)=C Next LP ' --------------------------------------------------------------------- ' >> Init the custom AGA copper list << ' --------------------------------------------------------------------- Screen 0 Hide On Copper Off Gosub BUILD_COPPER0 Gosub INIT_BITPLANE_POINTERS ' BEWARE this a work around to allow us to SET the AGA display burst mode ' although it's only set to 16 bit... Loke SRC0_BURST_ADR,$1FC1001 : Rem --- FORCE burst mode ! Cop Swap Wait Vbl ' --------------------------------------------------------------------- ' Render Stuff into the test bitmaps ' --------------------------------------------------------------------- Gosub RENDER_BACKDROP STRINGSCREENA=0 STRINGSCREENB=1 STRINGCOLOUR=192 : Rem range (0 To 255 :) YPOS=8 S$="Welcome to a simple custom AGA example screen for AMOS" Gosub DISPLAY_STRING_AGA YPOS=YPOS+5 S$="to begin a simple 256 colour demo !!" Gosub DISPLAY_STRING_AGA YPOS=YPOS+5 S$="PRESS ANY KEY" Gosub DISPLAY_STRING_AGA Wait Key CCYCLE=1 CCYCLEDIR=1 DEMOMAINLP3: For LP=0 To OBJECTS-1 X=OBJ(LP,0) Y=OBJ(LP,1) XS=OBJ(LP,2) YS=OBJ(LP,3) C=OBJ(LP,4) X=X+XS Y=Y+YS OBJ(LP,0)=X OBJ(LP,1)=Y XPOS=X/$100 YPOS=Y/$100 If XPOS=>(600-16) or XPOS<=40 Then XS=XS*-1 If YPOS>(230-16) or YPOS<20 Then YS=YS*-1 OBJ(LP,2)=XS OBJ(LP,3)=YS Screen 0 : Ink CCYCLE : Bar XPOS,YPOS To XPOS+16,YPOS+16 ' Screen 1 : Ink C : Bar XPOS,YPOS To XPOS+16,YPOS+16 Next LP Add CCYCLE,CCYCLEDIR If CCYCLE=1 Then CCYCLEDIR=CCYCLEDIR*-1 If CCYCLE=15 Then CCYCLEDIR=CCYCLEDIR*-1 K$=Inkey$ : If K$="" Then Goto DEMOMAINLP3 Screen 1 DEMOMAINLP: For LP=0 To 1500 X=Rnd(640-16) Y=Rnd(256-16) Screen 0 : Ink 0 : Bar X,Y To X+16,Y+16 Screen 1 : Ink 0 : Bar X,Y To X+16,Y+16 Next LP Screen 0 : Cls 0 : Screen 1 : Cls 0 YPOS=15 S$="DONE - PRESS ANY KEY" Gosub DISPLAY_STRING_AGA Wait Key Screen 0 : Screen To Front Copper On _FLUSH_DISPLAY_HARDWARE End ' --------------------------------------------------------------------- ' Simple Display 8 bit text routine ' --------------------------------------------------------------------- DISPLAY_STRING_AGA: Writing 1 SCLOW=STRINGCOLOUR and $F SCHIGH=STRINGCOLOUR/16 Screen STRINGSCREENA : Locate ,YPOS : Pen SCLOW : Centre S$ Screen STRINGSCREENB : Locate ,YPOS : Pen SCHIGH : Centre S$ Return ' --------------------------------------------------------------------- ' Fill in bitmap with our texture image ' --------------------------------------------------------------------- RENDER_BACKDROP: X=0 C=0 Screen 1 For I=0 To 5-1 Screen Copy 2,0,0,128,256 To 0,X,0 Ink C : Bar X,0 To X+128,85 : Inc C Ink C : Bar X,86 To X+128,172 : Inc C Ink C : Bar X,173 To X+128,255 : Inc C X=X+128 Next I Return ' --------------------------------------------------------------------- ' >> Lets create our CUSTOM AGA copper list << ' --------------------------------------------------------------------- ' This routine simply uses the 'AMOS' copper creation code, to build up ' our new custom list ' Warning: This source is not meant to teach you how the copper or ' for that how the amiga's gfx hardware is used directly. BUILD_COPPER0: THECOP_ADDR=Cop Logic TCA=THECOP_ADDR COP_DFF100=TCA Cop Move $100,%1000001000010000 : Rem ;SETHIRES ' Cop Move $100,%1000010000 : Rem ;SET 8 bit Low res Add TCA,4 Cop Move $102,0 : Add TCA,4 Cop Move $104,$200 : Add TCA,4 : Rem Kill EXTRA HALF BRIGHT mod E SRC0_BURST_ADR=TCA Cop Move $180,0 : Rem Dummy cop move, this becomes FMODE register Add TCA,4 SRC0_BP_ADDR=TCA NUMB_OF_BITPLANES=8 Gosub INSERT_AGACOPPER_BITPLANES ' odd and even modulos Cop Move $108,0 : Add TCA,4 Cop Move $10A,0 : Add TCA,4 ' Set up display limits. Cop Move $92,$38 : Add TCA,4 Cop Move $94,$D0 : Add TCA,4 Cop Move $8E,$2A81 : Add TCA,4 Cop Move $90,$2AC1 : Add TCA,4 Cop Move $10C,$77 : Add TCA,4 Rem Custom coppers 24bit palette registers ' Pal_offset ='s the current colour being added to the copper list CUR_COLOUR=0 ' first 32 colours 0-> 31 COP_COLBANK1=$C40 COP_COLBANK2=$E40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK ' colours 31->64 COP_COLBANK1=$2C40 COP_COLBANK2=$2E40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK ' colour 64->96 COP_COLBANK1=$4C40 COP_COLBANK2=$4E40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK COP_COLBANK1=$6C40 COP_COLBANK2=$6E40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK COP_COLBANK1=$8C40 COP_COLBANK2=$8E40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK COP_COLBANK1=$AC40 COP_COLBANK2=$AE40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK COP_COLBANK1=$CC40 COP_COLBANK2=$CE40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK COP_COLBANK1=$EC40 COP_COLBANK2=$EE40 Gosub CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK ' add a simple but nice little 24 bit blue rainbow ;) B=0 For RLP=0 To 250 C1=B and $F C2=(B and $F0)/16 Cop Wait $0,50+RLP Cop Move $106,$C40 Cop Move $180,C2 Cop Move $106,$E40 Cop Move $180,C1 Inc B Next RLP Cop Move $106,$C40 ' end of copper list Cop Wait 254,255 Cop Wait 254,255 Rem - Swap Logical and physical copper lists Return ' ----------------------------------------------------------------------- ' Insert Bitplane registers into a custom copper list ' ----------------------------------------------------------------------- ' inputs: NUMB_OF_BITPLANES = 1 up to a max of 8 INSERT_AGACOPPER_BITPLANES: If NUMB_OF_BITPLANES>8 Then NUMB_OF_BITPLANES=8 BITPLANE=$E0 For COP_LP=0 To NUMB_OF_BITPLANES-1 Cop Move BITPLANE,0 : Add TCA,4 Cop Move BITPLANE+2,0 : Add TCA,4 Add BITPLANE,4 Next COP_LP Return ' --------------------------------------------------------------------- ' >> INit copper bitplane pointers << ' --------------------------------------------------------------------- INIT_BITPLANE_POINTERS: P=SRC0_BP_ADDR For LP=0 To 8-1 BP=BITPLANES(LP) BP2=(BP and $FFFF0000)/$10000 BP=BP and $FFFF Doke P+2,BP2 Doke P+6,BP P=P+8 Next LP Return ' ----------------------------------------------------------------------- ' Insert a bank of 32 colour registers into our custom coper list ' ----------------------------------------------------------------------- CREATE_CUSTOM_COPPER_ADD_24BIT_COLOUR_BANK: Cop Move $106,COP_COLBANK1 : Add TCA,4 HW=$180 For C=0 To 32-1 Z=PALCOLOUR(CUR_COLOUR+C) Z=Z and $F0F0F0 Z=Z/16 R=(Z and $FF0000)/$10000 G=(Z and $FF00)/$100 B=Z and $FF RGB=(R*$100)+(G*$10)+B Cop Move HW,RGB : Add TCA,4 : Add HW,2 Next C Cop Move $106,COP_COLBANK2 : Add TCA,4 HW=$180 For C=0 To 32-1 Z=PALCOLOUR(CUR_COLOUR+C) Z2=Z and $F0F0F R=(Z2 and $FF0000)/$10000 G=(Z2 and $FF00)/$100 B=Z2 and $FF RGB=(R*$100)+(G*$10)+B Cop Move HW,RGB : Add TCA,4 : Add HW,2 Next C Add CUR_COLOUR,32 Return '--------------------------------------------------------------------- ' READ PALETTE '--------------------------------------------------------------------- GT_256COL_PALETTE: For LP=0 To 256-1 Read C PALCOLOUR(LP)=C Next LP Return '--------------------------------------------------------------------- ' Palette Data '--------------------------------------------------------------------- Rem AMBER HAZE-PALLETE Data $0,$FFFFEE,$EEEEBB,$DDCC77 Data $CCBB44,$BBAA33,$AA9922,$998811 Data $887711,$776600,$665500,$554400 Data $443300,$332200,$222200,$111100 Rem AQUAMARINE-PALLETE Data $0,$CCCCFF,$BBBBFF,$99AAEE Data $8888DD,$7777CC,$6666BB,$4466AA Data $445599,$334488,$224477,$113366 Data $112255,$2244,$1133,$1122 'BOO-BERRY-BLOO-PALLETE Data $0,$CCCCFF,$BBBBFF,$99AAEE Data $8888DD,$7777CC,$6666BB,$4466AA Data $445599,$334488,$224477,$113366 Data $112255,$2244,$1133,$1122 'CHOCOLATE GOLD-PALLETE Data $0,$FFFFEE,$EEEEBB,$DDCC77 Data $CCBB44,$AA9922,$998811,$887711 Data $777700,$666600,$555500,$444400 Data $333300,$222200,$111100,$111100 'CHROME MONEY GREEN-PALLETE Data $0,$EEFFFF,$CCFFFF,$99FFFF Data $66EEEE,$44DDDD,$33BBBB,$119999 Data $8888,$6666,$5555,$4444 Data $3333,$2222,$1111,$1111 'CLOCKWORK or ANGE-PALLETE Data $0,$FFFFFF,$FFDDCC,$FFBB88 Data $FF9944,$FF7700,$EE6600,$CC6600 Data $AA5500,$994400,$884400,$773300 Data $552200,$442200,$331100,$221100 'CORRECTED COBALT PALLETE Data $0,$CCCCFF,$BBBBFF,$99AAEE Data $8888DD,$7777CC,$6666BB,$5555AA Data $445599,$334488,$223377,$112266 Data $2255,$1144,$1133,$1122 'ELECTRIC CINNAMON-PALLETE Data $0,$FFFFFF,$FFDDDD,$FFCCBB Data $FFAA99,$FF8866,$FF6644,$FF4422 Data $FF2200,$DD1100,$BB1100,$990000 Data $770000,$550000,$330000,$110000 'ELECTRIC-LIME-PALLETE Data $0,$FFFFFF,$CCFFEE,$99FFCC Data $66FFAA,$33FF88,$FF66,$EE55 Data $CC33,$BB22,$9922,$7711 Data $6600,$4400,$2200,$1100 'FROSTBITE-PALLETE Data $0,$FFFFFF,$DDEEFF,$BBCCEE Data $99AAEE,$7799DD,$5577CC,$3366CC Data $2255BB,$1144AA,$112288,$2277 Data $1155,$44,$22,$11 'GRAPITY GRAPE PURPLE-PALLETE Data $0,$FFFFFF,$EEDDFF,$DDBBFF Data $CCAAEE,$BB88DD,$AA66CC,$9955BB Data $884499,$773388,$662277,$551166 Data $440044,$330033,$220022,$110011 'HEAVY STAIN BLUE-PALLETE Data $0,$EEEEFF,$CCCCFF,$9999EE Data $6666EE,$4444DD,$2222CC,$1111AA Data $88,$66,$55,$44 Data $33,$22,$11,$11 'PINK PANTHER-PALLETE Data $0,$FFFFFF,$FFDDFF,$FFAAFF Data $EE99EE,$DD77CC,$CC66BB,$BB5599 Data $AA4488,$993366,$882255,$772244 Data $661122,$440011,$220000,$110000 'RainDROP-PALLETE Data $0,$FFFFFF,$DDDDFF,$CCCCFF Data $BBBBFF,$AAAAEE,$9999EE,$8888DD Data $7777CC,$6666AA,$555599,$444488 Data $333366,$222255,$111133,$111122 'SHINY COPPER-PALLETE Data $0,$FFFFEE,$FFFFBB,$EEEE88 Data $EEEE66,$DDDD33,$CCCC11,$AAAA00 Data $888800,$666600,$555500,$444400 Data $333300,$222200,$111100,$111100 'SOYLENT GREEN-PALLETE Data $0,$FFFFFF,$DDFFDD,$BBEEBB Data $99DDAA,$77CC88,$66BB66,$44BB55 Data $33AA44,$229933,$118822,$7711 Data $5500,$4400,$2200,$1100 '--------------------------------------------------------------------- ' Reset Display Hardware '--------------------------------------------------------------------- Procedure _FLUSH_DISPLAY_HARDWARE ' Originally I wanted to actually FLUSH the display hardware with ' the gfx lib function load view, but of course that didn't work ;) ' Areg(1)=0 : Rem SET A1 To 0 ' D=Gfxcall(-222) ' So here's a dirty solution - ;) Doke $DFF1FC,0 : Rem clear burst mode register End Proc '--------------------------------------------------------------------- ' On ERROR - CLEAN UP PROGRAM '--------------------------------------------------------------------- Procedure _CLEANUP _FLUSH_DISPLAY_HARDWARE End End Proc