First Spear Posted January 24, 2018 Share Posted January 24, 2018 Where can the latest IntyBASIC "constants.bas" be found for use with v1.2.9? The one I have looks like the included. Thanks! constants.bas REM -------------------------------------------------------------------------REM HEADER - CONSTANTS.BASREMREM Started by Mark Ball, July 2015REMREM Constants for use in IntyBASICREMREM HISTORYREM -------REM 1.00F 05/07/15 - First version.REM 1.01F 07/07/15 - Added disc directions.REM - Added background modes.REM - Minor comment changes.REM 1.02F 08/07/15 - Renamed constants.REM - Added background access information.REM - Adjustments to layout.REM 1.03F 08/07/15 - Fixed comment delimiter.REM 1.04F 11/07/15 - Added useful functions.REM - Added controller movement mask.REM 1.05F 11/07/15 - Added BACKGROUND constants.REM 1.06F 11/07/15 - Changed Y, X order to X, Y in DEF FN functions.REM 1.07F 11/07/15 - Added colour stack advance.REM 1.08F 12/07/15 - Added functions for sprite position handling.REM 1.09F 12/07/15 - Added a function for resetting a sprite.REM 1.10F 13/07/15 - Added keypad constants.REM 1.11F 13/07/15 - Added side button constants.REM 1.12F 13/07/15 - Updated sprite functions.REM 1.13F 19/07/15 - Added border masking constants.REM 1.14F 20/07/15 - Added a combined border masking constant.REM 1.15F 20/07/15 - Renamed border masking constants to BORDER_HIDE_xxxx.REM 1.16F 28/09/15 - Fixed disc direction typos.REM 1.17F 30/09/15 - Fixed DISC_SOUTH_WEST value.REM 1.18F 05/12/15 - Fixed BG_XXXX colours.REM 1.19F 01/01/16 - Changed name of BACKTAB constant to avoid confusion with #BACKTAB array.REM - Added pause key constants.REM 1.20F 14/01/16 - Added coloured squares mode's pixel colours.REM 1.21F 15/01/16 - Added coloured squares mode's X and Y limits.REM 1.22F 23/01/16 - Added PSG constants.REM 1.23F 24/01/16 - Fixed typo in PSG comments.REM 1.24F 16/11/16 - Added toggle DEF FN's for sprite's BEHIND, HIT and VISIBLE.REM -------------------------------------------------------------------------REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM Background information.REM -------------------------------------------------------------------------CONST BACKTAB_ADDR = $0200 ' Start of the BACKground TABle (BACKTAB) in RAM.CONST BACKGROUND_ROWS = 12 ' Height of the background in cards.CONST BACKGROUND_COLUMNS = 20 ' Width of the background in cards.REM -------------------------------------------------------------------------REM Background GRAM cards.REM -------------------------------------------------------------------------CONST BG00 = $0800CONST BG01 = $0808CONST BG02 = $0810CONST BG03 = $0818CONST BG04 = $0820CONST BG05 = $0828CONST BG06 = $0830CONST BG07 = $0838CONST BG08 = $0840CONST BG09 = $0848CONST BG10 = $0850CONST BG11 = $0858CONST BG12 = $0860CONST BG13 = $0868CONST BG14 = $0870CONST BG15 = $0878CONST BG16 = $0880CONST BG17 = $0888CONST BG18 = $0890CONST BG19 = $0898CONST BG20 = $08A0CONST BG21 = $08A8CONST BG22 = $08B0CONST BG23 = $08B8CONST BG24 = $08C0CONST BG25 = $08C8CONST BG26 = $08D0CONST BG27 = $08D8CONST BG28 = $08E0CONST BG29 = $08E8CONST BG30 = $08F0CONST BG31 = $08F8CONST BG32 = $0900CONST BG33 = $0908CONST BG34 = $0910CONST BG35 = $0918CONST BG36 = $0920CONST BG37 = $0928CONST BG38 = $0930CONST BG39 = $0938CONST BG40 = $0940CONST BG41 = $0948CONST BG42 = $0950CONST BG43 = $0958CONST BG44 = $0960CONST BG45 = $0968CONST BG46 = $0970CONST BG47 = $0978CONST BG48 = $0980CONST BG49 = $0988CONST BG50 = $0990CONST BG51 = $0998CONST BG52 = $09A0CONST BG53 = $09A8CONST BG54 = $09B0CONST BG55 = $09B8CONST BG56 = $09C0CONST BG57 = $09C8CONST BG58 = $09D0CONST BG59 = $09D8CONST BG60 = $09E0CONST BG61 = $09E8CONST BG62 = $09F0CONST BG63 = $09F8REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM GRAM card index numbers.REM -------------------------------------------------------------------------REM Note: For use with the "define" command.REM -------------------------------------------------------------------------CONST DEF00 = $0000CONST DEF01 = $0001CONST DEF02 = $0002CONST DEF03 = $0003CONST DEF04 = $0004CONST DEF05 = $0005CONST DEF06 = $0006CONST DEF07 = $0007CONST DEF08 = $0008CONST DEF09 = $0009CONST DEF10 = $000ACONST DEF11 = $000BCONST DEF12 = $000CCONST DEF13 = $000DCONST DEF14 = $000ECONST DEF15 = $000FCONST DEF16 = $0010CONST DEF17 = $0011CONST DEF18 = $0012CONST DEF19 = $0013CONST DEF20 = $0014CONST DEF21 = $0015CONST DEF22 = $0016CONST DEF23 = $0017CONST DEF24 = $0018CONST DEF25 = $0019CONST DEF26 = $001ACONST DEF27 = $001BCONST DEF28 = $001CCONST DEF29 = $001DCONST DEF30 = $001ECONST DEF31 = $001FCONST DEF32 = $0020CONST DEF33 = $0021CONST DEF34 = $0022CONST DEF35 = $0023CONST DEF36 = $0024CONST DEF37 = $0025CONST DEF38 = $0026CONST DEF39 = $0027CONST DEF40 = $0028CONST DEF41 = $0029CONST DEF42 = $002ACONST DEF43 = $002BCONST DEF44 = $002CCONST DEF45 = $002DCONST DEF46 = $002ECONST DEF47 = $002FCONST DEF48 = $0030CONST DEF49 = $0031CONST DEF50 = $0032CONST DEF51 = $0033CONST DEF52 = $0034CONST DEF53 = $0035CONST DEF54 = $0036CONST DEF55 = $0037CONST DEF56 = $0038CONST DEF57 = $0039CONST DEF58 = $003ACONST DEF59 = $003BCONST DEF60 = $003CCONST DEF61 = $003DCONST DEF62 = $003ECONST DEF63 = $003FREM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM Screen modes.REM -------------------------------------------------------------------------REM Note: For use with the "mode" command.REM -------------------------------------------------------------------------CONST SCREEN_COLOR_STACK = $0000CONST SCREEN_FOREGROUND_BACKGROUND = $0001REM Abbreviated versions.CONST SCREEN_CS = $0000CONST SCREEN_FB = $0001REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM COLORS - Border.REM -------------------------------------------------------------------------REM Notes:REM - For use with the commands "mode 0" and "mode 1".REM - For use with the "border" command.REM -------------------------------------------------------------------------CONST BORDER_BLACK = $0000CONST BORDER_BLUE = $0001CONST BORDER_RED = $0002CONST BORDER_TAN = $0003CONST BORDER_DARKGREEN = $0004CONST BORDER_GREEN = $0005CONST BORDER_YELLOW = $0006CONST BORDER_WHITE = $0007CONST BORDER_GREY = $0008CONST BORDER_CYAN = $0009CONST BORDER_ORANGE = $000ACONST BORDER_BROWN = $000BCONST BORDER_PINK = $000CCONST BORDER_LIGHTBLUE = $000DCONST BORDER_YELLOWGREEN = $000ECONST BORDER_PURPLE = $000FREM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM BORDER - Edge masks.REM -------------------------------------------------------------------------REM Note: For use with the "border color, edge" command.REM -------------------------------------------------------------------------CONST BORDER_HIDE_LEFT_EDGE = $0001 ' Hide the leftmost column of the background.CONST BORDER_HIDE_TOP_EDGE = $0002 ' Hide the topmost row of the background.CONST BORDER_HIDE_TOP_LEFT_EDGE = $0003 ' Hide both the topmost row and leftmost column of the background.REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM COLORS - Mode 0 (Color Stack).REM -------------------------------------------------------------------------REM StackREM -------------------------------------------------------------------------REM Note: For use as the last 4 parameters used in the "mode 1" command.REM -------------------------------------------------------------------------CONST STACK_BLACK = $0000CONST STACK_BLUE = $0001CONST STACK_RED = $0002CONST STACK_TAN = $0003CONST STACK_DARKGREEN = $0004CONST STACK_GREEN = $0005CONST STACK_YELLOW = $0006CONST STACK_WHITE = $0007CONST STACK_GREY = $0008CONST STACK_CYAN = $0009CONST STACK_ORANGE = $000ACONST STACK_BROWN = $000BCONST STACK_PINK = $000CCONST STACK_LIGHTBLUE = $000DCONST STACK_YELLOWGREEN = $000ECONST STACK_PURPLE = $000FREM -------------------------------------------------------------------------REM Foreground.REM -------------------------------------------------------------------------REM Notes:REM - For use with "peek/poke" commands that access BACKTAB.REM - Only one foreground colour permitted per background card.REM -------------------------------------------------------------------------CONST CS_BLACK = $0000CONST CS_BLUE = $0001CONST CS_RED = $0002CONST CS_TAN = $0003CONST CS_DARKGREEN = $0004CONST CS_GREEN = $0005CONST CS_YELLOW = $0006CONST CS_WHITE = $0007CONST CS_GREY = $1000CONST CS_CYAN = $1001CONST CS_ORANGE = $1002CONST CS_BROWN = $1003CONST CS_PINK = $1004CONST CS_LIGHTBLUE = $1005CONST CS_YELLOWGREEN = $1006CONST CS_PURPLE = $1007CONST CS_CARD_DATA_MASK = $07F8 ' Mask to get the background card's data.CONST CS_ADVANCE = $2000 ' Advance the colour stack by one position.REM -------------------------------------------------------------------------REM Coloured squares mode.REM -------------------------------------------------------------------------REM Notes :REM - Only available in colour stack mode.REM - Pixels in each BACKTAB card are arranged in the following manner:REM +-------+-------+REM | Pixel | Pixel |REM | 0 | 1 !REM +-------+-------+REM | Pixel | Pixel |REM | 2 | 3 !REM +-------+-------+REMREM -------------------------------------------------------------------------CONST CS_COLOUR_SQUARES_ENABLE =$1000CONST CS_PIX0_BLACK =0CONST CS_PIX0_BLUE =1CONST CS_PIX0_RED =2CONST CS_PIX0_TAN =3CONST CS_PIX0_DARKGREEN =4CONST CS_PIX0_GREEN =5CONST CS_PIX0_YELLOW =6CONST CS_PIX0_BACKGROUND =7CONST CS_PIX1_BLACK =0CONST CS_PIX1_BLUE =1*8CONST CS_PIX1_RED =2*8CONST CS_PIX1_TAN =3*8CONST CS_PIX1_DARKGREEN =4*8CONST CS_PIX1_GREEN =5*8CONST CS_PIX1_YELLOW =6*8CONST CS_PIX1_BACKGROUND =7*8CONST CS_PIX2_BLACK =0CONST CS_PIX2_BLUE =1*64CONST CS_PIX2_RED =2*64CONST CS_PIX2_TAN =3*64CONST CS_PIX2_DARKGREEN =4*64CONST CS_PIX2_GREEN =5*64CONST CS_PIX2_YELLOW =6*64CONST CS_PIX2_BACKGROUND =7*64CONST CS_PIX3_BLACK =0CONST CS_PIX3_BLUE =$0200CONST CS_PIX3_RED =$0400CONST CS_PIX3_TAN =$0600CONST CS_PIX3_DARKGREEN =$2000CONST CS_PIX3_GREEN =$2200CONST CS_PIX3_YELLOW =$2400CONST CS_PIX3_BACKGROUND =$2600CONST CS_PIX_MASK =CS_COLOUR_SQUARES_ENABLE+CS_PIX0_BACKGROUND+CS_PIX1_BACKGROUND+CS_PIX2_BACKGROUND+CS_PIX3_BACKGROUNDCONST CS_PIX_X_MIN =0 ' Minimum x coordinate.CONST CS_PIX_X_MAX =39 ' Maximum x coordinate.CONST CS_PIX_Y_MIN =0 ' Minimum Y coordinate.CONST CS_PIX_Y_MAX =23 ' Maximum Y coordinate.REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM COLORS - Mode 1 (Foreground Background)REM -------------------------------------------------------------------------REM Foreground.REM -------------------------------------------------------------------------REM Notes:REM - For use with "peek/poke" commands that access BACKTAB.REM - Only one foreground colour permitted per background card.REM -------------------------------------------------------------------------CONST FG_BLACK = $0000CONST FG_BLUE = $0001CONST FG_RED = $0002CONST FG_TAN = $0003CONST FG_DARKGREEN = $0004CONST FG_GREEN = $0005CONST FG_YELLOW = $0006CONST FG_WHITE = $0007REM -------------------------------------------------------------------------REM Background.REM -------------------------------------------------------------------------REM Notes:REM - For use with "peek/poke" commands that access BACKTAB.REM - Only one background colour permitted per background card.REM -------------------------------------------------------------------------CONST BG_BLACK = $0000CONST BG_BLUE = $0200CONST BG_RED = $0400CONST BG_TAN = $0600CONST BG_DARKGREEN = $2000CONST BG_GREEN = $2200CONST BG_YELLOW = $2400CONST BG_WHITE = $2600CONST BG_GREY = $1000CONST BG_CYAN = $1200CONST BG_ORANGE = $1400CONST BG_BROWN = $1600CONST BG_PINK = $3000CONST BG_LIGHTBLUE = $3200CONST BG_YELLOWGREEN = $3400CONST BG_PURPLE = $3600CONST FGBG_CARD_DATA_MASK = $01F8 ' Mask to get the background card's data.REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM Sprites.REM -------------------------------------------------------------------------REM Note: For use with "sprite" command.REM -------------------------------------------------------------------------REM XREM -------------------------------------------------------------------------REM Note: Add these constants to the sprite command's X parameter.REM -------------------------------------------------------------------------CONST HIT = $0100 ' Enable the sprite's collision detection.CONST VISIBLE = $0200 ' Make the sprite visible.CONST ZOOMX2 = $0400 ' Make the sprite twice the width.REM -------------------------------------------------------------------------REM YREM -------------------------------------------------------------------------REM Note: Add these constants to the sprite command's Y parameter.REM -------------------------------------------------------------------------CONST DOUBLEY = $0080 ' Make a double height sprite (with 2 GRAM cards).CONST ZOOMY2 = $0100 ' Make the sprite twice (x2) the normal height.CONST ZOOMY4 = $0200 ' Make the sprite quadruple (x4) the normal height.CONST ZOOMY8 = $0300 ' Make the sprite octuple (x8) the normal height.CONST FLIPX = $0400 ' Flip/mirror the sprite in X.CONST FLIPY = $0800 ' Flip/mirror the sprite in Y.CONST MIRROR = $0C00 ' Flip/mirror the sprite in both X and Y.REM -------------------------------------------------------------------------REM AREM -------------------------------------------------------------------------REM Notes:REM - Combine to create the sprite command's A parameter.REM - Only one colour per sprite.REM -------------------------------------------------------------------------CONST GRAM = $0800 ' Sprite's data is located in GRAM.CONST BEHIND = $2000 ' Sprite is behind the background.CONST SPR_BLACK = $0000CONST SPR_BLUE = $0001CONST SPR_RED = $0002CONST SPR_TAN = $0003CONST SPR_DARKGREEN = $0004CONST SPR_GREEN = $0005CONST SPR_YELLOW = $0006CONST SPR_WHITE = $0007CONST SPR_GREY = $1000CONST SPR_CYAN = $1001CONST SPR_ORANGE = $1002CONST SPR_BROWN = $1003CONST SPR_PINK = $1004CONST SPR_LIGHTBLUE = $1005CONST SPR_YELLOWGREEN = $1006CONST SPR_PURPLE = $1007REM -------------------------------------------------------------------------REM GRAM numbers.REM -------------------------------------------------------------------------REM Note: For use in the sprite command's parameter A.REM -------------------------------------------------------------------------CONST SPR00 = $0800CONST SPR01 = $0808CONST SPR02 = $0810CONST SPR03 = $0818CONST SPR04 = $0820CONST SPR05 = $0828CONST SPR06 = $0830CONST SPR07 = $0838CONST SPR08 = $0840CONST SPR09 = $0848CONST SPR10 = $0850CONST SPR11 = $0858CONST SPR12 = $0860CONST SPR13 = $0868CONST SPR14 = $0870CONST SPR15 = $0878CONST SPR16 = $0880CONST SPR17 = $0888CONST SPR18 = $0890CONST SPR19 = $0898CONST SPR20 = $08A0CONST SPR21 = $08A8CONST SPR22 = $08B0CONST SPR23 = $08B8CONST SPR24 = $08C0CONST SPR25 = $08C8CONST SPR26 = $08D0CONST SPR27 = $08D8CONST SPR28 = $08E0CONST SPR29 = $08E8CONST SPR30 = $08F0CONST SPR31 = $08F8CONST SPR32 = $0900CONST SPR33 = $0908CONST SPR34 = $0910CONST SPR35 = $0918CONST SPR36 = $0920CONST SPR37 = $0928CONST SPR38 = $0930CONST SPR39 = $0938CONST SPR40 = $0940CONST SPR41 = $0948CONST SPR42 = $0950CONST SPR43 = $0958CONST SPR44 = $0960CONST SPR45 = $0968CONST SPR46 = $0970CONST SPR47 = $0978CONST SPR48 = $0980CONST SPR49 = $0988CONST SPR50 = $0990CONST SPR51 = $0998CONST SPR52 = $09A0CONST SPR53 = $09A8CONST SPR54 = $09B0CONST SPR55 = $09B8CONST SPR56 = $09C0CONST SPR57 = $09C8CONST SPR58 = $09D0CONST SPR59 = $09D8CONST SPR60 = $09E0CONST SPR61 = $09E8CONST SPR62 = $09F0CONST SPR63 = $09F8REM -------------------------------------------------------------------------REM Sprite collision.REM -------------------------------------------------------------------------REM Notes:REM - For use with variables COL0, COL1, COL2, COL3, COL4, COL5, COL6 and COL7.REM - More than one collision can occur simultaneously.REM -------------------------------------------------------------------------CONST HIT_SPRITE0 = $0001 ' Sprite collided with sprite 0.CONST HIT_SPRITE1 = $0002 ' Sprite collided with sprite 1.CONST HIT_SPRITE2 = $0004 ' Sprite collided with sprite 2.CONST HIT_SPRITE3 = $0008 ' Sprite collided with sprite 3.CONST HIT_SPRITE4 = $0010 ' Sprite collided with sprite 4.CONST HIT_SPRITE5 = $0020 ' Sprite collided with sprite 5.CONST HIT_SPRITE6 = $0040 ' Sprite collided with sprite 6.CONST HIT_SPRITE7 = $0080 ' Sprite collided with sprite 7.CONST HIT_BACKGROUND = $0100 ' Sprite collided with a background pixel.CONST HIT_BORDER = $0200 ' Sprite collided with the top/bottom/left/right border.REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM DISC - Compass.REM -------------------------------------------------------------------------REM NW N NEREM \ NNW | NNE /REM \ | /REM \ | /REM WNW \ | / ENEREM \|/REM W ----------+---------- EREM /|\REM WSW / | \ ESEREM / | \REM / | \REM / SSW | SSE \REM SW S SEREM -------------------------------------------------------------------------REM Notes:REM - North points upwards on the hand controller.REM - Directions are listed in a clockwise manner.REM -------------------------------------------------------------------------CONST DISC_NORTH = $0004CONST DISC_NORTH_NORTH_EAST = $0014CONST DISC_NORTH_EAST = $0016CONST DISC_EAST_NORTH_EAST = $0006CONST DISC_EAST = $0002CONST DISC_EAST_SOUTH_EAST = $0012CONST DISC_SOUTH_EAST = $0013CONST DISC_SOUTH_SOUTH_EAST = $0003CONST DISC_SOUTH = $0001CONST DISC_SOUTH_SOUTH_WEST = $0011CONST DISC_SOUTH_WEST = $0019CONST DISC_WEST_SOUTH_WEST = $0009CONST DISC_WEST = $0008CONST DISC_WEST_NORTH_WEST = $0018CONST DISC_NORTH_WEST = $001CCONST DISC_NORTH_NORTH_WEST = $000CREM -------------------------------------------------------------------------REM DISC - Compass abbreviated versions.REM -------------------------------------------------------------------------CONST DISC_N = $0004CONST DISC_NNE = $0014CONST DISC_NE = $0016CONST DISC_ENE = $0006CONST DISC_E = $0002CONST DISC_ESE = $0012CONST DISC_SE = $0013CONST DISC_SSE = $0003CONST DISC_S = $0001CONST DISC_SSW = $0011CONST DISC_SW = $0019CONST DISC_WSW = $0009CONST DISC_W = $0008CONST DISC_WNW = $0018CONST DISC_NW = $001CCONST DISC_NNW = $000CREM -------------------------------------------------------------------------REM DISC - Directions.REM -------------------------------------------------------------------------CONST DISC_UP = $0004CONST DISC_UP_RIGHT = $0016 ' Up and right diagonal.CONST DISC_RIGHT = $0002CONST DISC_DOWN_RIGHT = $0013 ' Down and right diagonal.CONST DISC_DOWN = $0001CONST DISC_DOWN_LEFT = $0019 ' Down and left diagonal.CONST DISC_LEFT = $0008CONST DISC_UP_LEFT = $001C ' Up and left diagonal.REM -------------------------------------------------------------------------REM DISK - Mask.REM -------------------------------------------------------------------------CONST DISK_MASK = $001FREM -------------------------------------------------------------------------REM Controller - Keypad.REM -------------------------------------------------------------------------CONST KEYPAD_0 = 72CONST KEYPAD_1 = 129CONST KEYPAD_2 = 65CONST KEYPAD_3 = 33CONST KEYPAD_4 = 130CONST KEYPAD_5 = 66CONST KEYPAD_6 = 34CONST KEYPAD_7 = 132CONST KEYPAD_8 = 68CONST KEYPAD_9 = 36CONST KEYPAD_CLEAR = 136CONST KEYPAD_ENTER = 40REM -------------------------------------------------------------------------REM Controller - Pause buttons (1+9 or 3+7 held down simultaneously).REM -------------------------------------------------------------------------REM Notes:REM - Key codes for 3+7 and 1+9 are the same (165).REM -------------------------------------------------------------------------CONST KEYPAD_PAUSE = (KEYPAD_1 XOR KEYPAD_9)REM -------------------------------------------------------------------------REM Controller - Side buttons.REM -------------------------------------------------------------------------CONST BUTTON_TOP_LEFT = $A0 ' Top left and top right are the same button.CONST BUTTON_TOP_RIGHT = $A0 ' Note: Bit 6 is low.CONST BUTTON_BOTTOM_LEFT = $60 ' Note: Bit 7 is low.CONST BUTTON_BOTTOM_RIGHT = $C0 ' Note: Bit 5 is lowREM Abbreviated versions.CONST BUTTON_1 = $A0 ' Top left or top right.CONST BUTTON_2 = $60 ' Bottom left.CONST BUTTON_3 = $C0 ' Bottom right.REM Mask.CONST BUTTON_MASK = $E0REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM Programmable Sound Generator (PSG)REM -------------------------------------------------------------------------REM Notes:REM - For use with the SOUND commandREM -------------------------------------------------------------------------REM -------------------------------------------------------------------------REM Internal sound hardware.REM -------------------------------------------------------------------------CONST PSG_CHANNELA =0CONST PSG_CHANNELB =1CONST PSG_CHANNELC =2CONST PSG_ENVELOPE =3CONST PSG_MIXER =4REM -------------------------------------------------------------------------REM ECS sound hardware.REM -------------------------------------------------------------------------CONST PSG_ECS_CHANNELA =5CONST PSG_ECS_CHANNELB =6CONST PSG_ECS_CHANNELC =7CONST PSG_ECS_ENVELOPE =8CONST PSG_ECS_MIXER =9REM -------------------------------------------------------------------------REM PSG - Volume control.REM -------------------------------------------------------------------------REM Notes:REM - For use in the volume field of the SOUND command.REM - Internal channels: PSG_CHANNELA, PSG_CHANNELB, PSG_CHANNELCREM - ECS channels: PSG_ECS_CHANNELA, PSG_ECS_CHANNELB, PSG_ECS_CHANNELCREM -------------------------------------------------------------------------CONST PSG_VOLUME_MAX =15 ' Maximum channel volume.CONST PSG_ENVELOPE_ENABLE =48 ' Channel volume is controlled by envelope generator.REM -------------------------------------------------------------------------REM PSG - Mixer control.REM -------------------------------------------------------------------------REM Notes:REM - Internal channel: PSG_MIXERREM - ECS channel: PSG_ECS_MIXERREM -------------------------------------------------------------------------CONST PSG_TONE_CHANNELA_DISABLE =$01 ' Disable channel A tone.CONST PSG_TONE_CHANNELB_DISABLE =$02 ' Disable channel B tone.CONST PSG_TONE_CHANNELC_DISABLE =$04 ' Disable channel C tone.CONST PSG_NOISE_CHANNELA_DISABLE =$08 ' Disable channel A noise.CONST PSG_NOISE_CHANNELB_DISABLE =$10 ' Disable channel B noise.CONST PSG_NOISE_CHANNELC_DISABLE =$20 ' Disable channel C noise.CONST PSG_MIXER_DEFAULT =$38 ' All notes enabled. all noise disabled.REM -------------------------------------------------------------------------REM PSG - Envelope control.REM -------------------------------------------------------------------------REM Notes:REM - Internal channel: PSG_ENVELOPEREM - ECS channel: PSG_ECS_ENVELOPEREM -------------------------------------------------------------------------CONST PSG_ENVELOPE_HOLD =$01CONST PSG_ENVELOPE_ALTERNATE =$02CONST PSG_ENVELOPE_ATTACK =$04CONST PSG_ENVELOPE_CONTINUE =$08CONST PSG_ENVELOPE_SINGLE_SHOT_RAMP_DOWN_AND_OFF =$00 '\______CONST PSG_ENVELOPE_SINGLE_SHOT_RAMP_UP_AND_OFF =$04 '/______CONST PSG_ENVELOPE_CYCLE_RAMP_DOWN_SAWTOOTH =$08 '\\\\\\\CONST PSG_ENVELOPE_CYCLE_RAMP_DOWN_TRIANGLE =$0A '\/\/\/\CONST PSG_ENVELOPE_SINGLE_SHOT_RAMP_DOWN_AND_MAX =$0B '\^^^^^^CONST PSG_ENVELOPE_CYCLE_RAMP_UP_SAWTOOTH =$0C '///////CONST PSG_ENVELOPE_SINGLE_SHOT_RAMP_UP_AND_MAX =$0D '/^^^^^^CONST PSG_ENVELOPE_CYCLE_RAMP_UP_TRIANGLE =$0E '/\/\/\/REM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM Useful functions.REM -------------------------------------------------------------------------DEF FN screenpos(aColumn, aRow) = (((aRow)*BACKGROUND_COLUMNS)+(aColumn))DEF FN screenaddr(aColumn, aRow) = (BACKTAB_ADDR+(((aRow)*BACKGROUND_COLUMNS)+(aColumn)))DEF FN setspritex(aSpriteNo,anXPosition) = #mobshadow(aSpriteNo)=(#mobshadow(aSpriteNo) and $ff00)+anXPositionDEF FN setspritey(aSpriteNo,aYPosition) = #mobshadow(aSpriteNo+ =(#mobshadow(aSpriteNo+ and $ff80)+aYPositionDEF FN resetsprite(aSpriteNo) = sprite aSpriteNo, 0, 0, 0DEF FN togglespritevisible(aSpriteNo) = #mobshadow(aSpriteNo)=#mobshadow(aSpriteNo) xor VISIBLEDEF FN togglespritehit(aSpriteNo) = #mobshadow(aSpriteNo)=#mobshadow(aSpriteNo) xor HITDEF FN togglespritebehind(aSpriteNo) = #mobshadow(aSpriteNo+16)=#mobshadow(aSpriteNo+16) xor BEHINDREM /////////////////////////////////////////////////////////////////////////REM -------------------------------------------------------------------------REM ENDREM ------------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
+nanochess Posted January 24, 2018 Author Share Posted January 24, 2018 The latest constants.bas is always included with distribution with Mark blessing. 2 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted January 24, 2018 Share Posted January 24, 2018 Is there no way to use colored squares mode in IntyBASIC? I don't think I've ever tried it. Check out ColouredSquares.bas in the contrib folder of IntyBASIC. It draws lines in that mode. Quote Link to comment Share on other sites More sharing options...
carlsson Posted February 1, 2018 Share Posted February 1, 2018 Is this a general question/support thread? If so, is there any way to seed either of the random number generators in IntyBASIC, so you get a known sequence of pseudo random numbers? I don't see any mention of this in the manual, but perhaps it has been covered in the forum before. If not, I'm fine writing my own PRNG that has that ability. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 1, 2018 Share Posted February 1, 2018 I think the RAND uses the FRAME to generate a random number. I do not know whether or not you could write a new 16-bit number into this variable FRAME. This could be the seed for the RNG. 1 Quote Link to comment Share on other sites More sharing options...
carlsson Posted February 1, 2018 Share Posted February 1, 2018 Hm, I came to a similar conclusion. I might use the Defender of the Crown PRNG instead. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 1, 2018 Author Share Posted February 1, 2018 Is this a general question/support thread? If so, is there any way to seed either of the random number generators in IntyBASIC, so you get a known sequence of pseudo random numbers? I don't see any mention of this in the manual, but perhaps it has been covered in the forum before. If not, I'm fine writing my own PRNG that has that ability. It used to start at zero at boot, but now it's seeded with the random numbers remaining in RAM at boot. You can force it to a seed using: ASM MVI #value,R0 ; Anything between 0-255 ASM MVO R0,_rand 1 Quote Link to comment Share on other sites More sharing options...
carlsson Posted February 1, 2018 Share Posted February 1, 2018 (edited) I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG. Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible. ASM MVII #0,R0 ASM MVO R0,_rand ASM MVO R0,_frameThe reason I reset _frame is that it is involved in the routine _next_random. Edited February 1, 2018 by carlsson Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 1, 2018 Share Posted February 1, 2018 I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG. Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible. ASM MVII #0,R0 ASM MVO R0,_rand ASM MVO R0,_frameThe reason I reset _frame is that it is involved in the routine _next_random. _next_random is called from an interrupt service routine. So, if anything changes your timing relative to display refresh, that'll change your random number stream. 1 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 2, 2018 Author Share Posted February 2, 2018 I might try that later, except that I would first generate N "free flowing" random seeds that I assign to an array or similar, and then reseed the PRNG with respective seed. I will study the ASM file to figure out how such arrays normally are addressed. By placing the array as the first variable, I should be able to deterministically use inline assembly language to reseed the PRNG. Edit: I tried this, which for me appears like the random number sequence is similar, but not the exact same. Or perhaps I have another bug in my code, which is fully possible. ASM MVII #0,R0 ASM MVO R0,_rand ASM MVO R0,_frameThe reason I reset _frame is that it is involved in the routine _next_random. I think you should do a WAIT before running this code in order to synchronize state. 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 4, 2018 Share Posted February 4, 2018 In another thread, nanochess mentioned something about posting where IntyBASIC doesn't generate the best possible code. Here's one I recently noticed. I come from the C and C++ world, where writing a += b is exceedingly natural. It's supposed to be equivalent to writing a = a + b. Right now, at least for arrays, it turns out it's more efficient to write that as a = b + a, as the address of 'a' for the input gets loaded last, and reused for the result. Consider this input: . DIM #P(, #V(, #A( ASM ; This one sucks: FOR I = 0 TO 7 #V(I) = #V(I) + #A(I) #P(I) = #P(I) + #V(I) NEXT I ASM ; This one is much better: FOR I = 0 TO 7 #V(I) = #A(I) + #V(I) #P(I) = #V(I) + #P(I) NEXT I . Now lets look at the generated code. I've removed unnecessary comments/directives from the output to make it (hopefully) easier to follow. . ;FILE quality.bas ;[1] DIM #P(, #V(, #A( ;[3] ASM ; This one sucks: ; This one sucks: ;[4] FOR I = 0 TO 7 CLRR R0 MVO R0,V1 T1: ;[5] #V(I) = #V(I) + #A(I) MVII #Q4,R3 ADD V1,R3 MVI@ R3,R0 ADDI #(Q5-Q4) AND $FFFF,R3 ADD@ R3,R0 ADDI #(Q4-Q5) AND $FFFF,R3 MVO@ R0,R3 ;[6] #P(I) = #P(I) + #V(I) ADDI #(Q3-Q4) AND $FFFF,R3 MVI@ R3,R0 ADDI #(Q4-Q3) AND $FFFF,R3 ADD@ R3,R0 ADDI #(Q3-Q4) AND $FFFF,R3 MVO@ R0,R3 ;[7] NEXT I MVI V1,R0 INCR R0 MVO R0,V1 CMPI #7,R0 BLE T1 ;[9] ASM ; This one is much better: ; This one is much better: ;[10] FOR I = 0 TO 7 CLRR R0 MVO R0,V1 T2: ;[11] #V(I) = #A(I) + #V(I) MVII #Q5,R3 ADD V1,R3 MVI@ R3,R0 ADDI #(Q4-Q5) AND $FFFF,R3 ADD@ R3,R0 MVO@ R0,R3 ;[12] #P(I) = #V(I) + #P(I) MVI@ R3,R0 ADDI #(Q3-Q4) AND $FFFF,R3 ADD@ R3,R0 MVO@ R0,R3 ;[13] NEXT I MVI V1,R0 INCR R0 MVO R0,V1 CMPI #7,R0 BLE T2 . I'm not saying IntyBASIC needs a hardcore expression canonicalizer. I am saying, though, that IntyBASIC programmers should be aware that a = a + b may be noticeably more expensive than a = b + a, and that's a bit counter-intuitive. 2 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 4, 2018 Author Share Posted February 4, 2018 In another thread, nanochess mentioned something about posting where IntyBASIC doesn't generate the best possible code. Here's one I recently noticed. I come from the C and C++ world, where writing a += b is exceedingly natural. It's supposed to be equivalent to writing a = a + b. Right now, at least for arrays, it turns out it's more efficient to write that as a = b + a, as the address of 'a' for the input gets loaded last, and reused for the result. Consider this input: . DIM #P(, #V(, #A( ASM ; This one sucks: FOR I = 0 TO 7 #V(I) = #V(I) + #A(I) #P(I) = #P(I) + #V(I) NEXT I ASM ; This one is much better: FOR I = 0 TO 7 #V(I) = #A(I) + #V(I) #P(I) = #V(I) + #P(I) NEXT I .Now lets look at the generated code. I've removed unnecessary comments/directives from the output to make it (hopefully) easier to follow. . ;FILE quality.bas ;[1] DIM #P(, #V(, #A( ;[3] ASM ; This one sucks: ; This one sucks: ;[4] FOR I = 0 TO 7 CLRR R0 MVO R0,V1 T1: ;[5] #V(I) = #V(I) + #A(I) MVII #Q4,R3 ADD V1,R3 MVI@ R3,R0 ADDI #(Q5-Q4) AND $FFFF,R3 ADD@ R3,R0 ADDI #(Q4-Q5) AND $FFFF,R3 MVO@ R0,R3 ;[6] #P(I) = #P(I) + #V(I) ADDI #(Q3-Q4) AND $FFFF,R3 MVI@ R3,R0 ADDI #(Q4-Q3) AND $FFFF,R3 ADD@ R3,R0 ADDI #(Q3-Q4) AND $FFFF,R3 MVO@ R0,R3 ;[7] NEXT I MVI V1,R0 INCR R0 MVO R0,V1 CMPI #7,R0 BLE T1 ;[9] ASM ; This one is much better: ; This one is much better: ;[10] FOR I = 0 TO 7 CLRR R0 MVO R0,V1 T2: ;[11] #V(I) = #A(I) + #V(I) MVII #Q5,R3 ADD V1,R3 MVI@ R3,R0 ADDI #(Q4-Q5) AND $FFFF,R3 ADD@ R3,R0 MVO@ R0,R3 ;[12] #P(I) = #V(I) + #P(I) MVI@ R3,R0 ADDI #(Q3-Q4) AND $FFFF,R3 ADD@ R3,R0 MVO@ R0,R3 ;[13] NEXT I MVI V1,R0 INCR R0 MVO R0,V1 CMPI #7,R0 BLE T2 .I'm not saying IntyBASIC needs a hardcore expression canonicalizer. I am saying, though, that IntyBASIC programmers should be aware that a = a + b may be noticeably more expensive than a = b + a, and that's a bit counter-intuitive. I could enhance this. BTW it was even worst before you suggested the ADD offset feature. 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted February 4, 2018 Share Posted February 4, 2018 I could enhance this. BTW it was even worst before you suggested the ADD offset feature. I like it! 2 Quote Link to comment Share on other sites More sharing options...
carlsson Posted February 7, 2018 Share Posted February 7, 2018 I think you should do a WAIT before running this code in order to synchronize state. Thanks, this solved my problem. Partial code snippets: DIM seeds(15) SIGNED sx,sy FOR i=0 TO 14 seeds(i)=RANDOM(255) NEXT sx=2:sy=1 loop: i=seeds(sy*5+sx) WAIT ASM MVI V1,R0 : REM i is the first regular variable used in my program, so it happens to become V1 ASM MVO R0,_rand ASM MVO R0,_frame [..] j=RANDOM(255) [..] This lets me reseed the built-in random number generator with 15 different seeds grabbed at the beginning of the program and get the same stream of random numbers after reseeding. I don't know what the by-effects are from resetting the frame counter. 1 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 7, 2018 Author Share Posted February 7, 2018 ... I don't know what the by-effects are from resetting the frame counter. None for IntyBASIC core. It's simply a counter being incremented in each frame. 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted February 7, 2018 Share Posted February 7, 2018 I don't know what the by-effects are from resetting the frame counter. If you are using it to count frames for, say, animations; then you may end up repeating frames. However, I would imagine that you would only reseed the PRNG during game transitions and initializations, so I wouldn't expect there to be any effect at all. -dZ. 1 Quote Link to comment Share on other sites More sharing options...
artrag Posted February 11, 2018 Share Posted February 11, 2018 Question about PLAY: I need to pause a song, use all psg channels for a while, and then restart the song where it was at the time of the pause. I've tried with PLAY OFF but then I do not know how to make music restart form the position where it was... Any suggestion ? Quote Link to comment Share on other sites More sharing options...
artrag Posted February 11, 2018 Share Posted February 11, 2018 (edited) Aside from the question above I have a feature request. Would it be possible to extend the music player to 6 channels when the ECS module is detected? I do not remember if the subject has been already touched. Edited February 12, 2018 by artrag Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 12, 2018 Author Share Posted February 12, 2018 Question about PLAY: I need to pause a song, use all psg channels for a while, and then restart the song where it was at the time of the pause. I've tried with PLAY OFF but then I do not know how to make music restart form the position where it was... Any suggestion ? Use PLAY NONE, put all channels volume to zero, and then do whatever you want, to restart music tracker use PLAY SIMPLE or PLAY FULL as you were using. Aside from the question above I have a feature request. Would it be possible to extend the music player to 6 channels when the ECS module is detected? Ai do not remember if the subject has been already touched. I'm thinking on it, I know it will use a lot of precious 16-bit variables. 1 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 12, 2018 Share Posted February 12, 2018 (edited) I'm thinking on it, I know it will use a lot of precious 16-bit variables. The ECS module does come with 2KB of RAM. I'm unsure if it is 16-bit RAM or 8-bit RAM. EDIT: Nevermind, groovybee said it's 8-bit wide in this thread. http://atariage.com/forums/topic/212917-entertainment-computer-system-is-it-worth-owning/?p=3296479 Edited February 12, 2018 by Kiwi Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted February 12, 2018 Share Posted February 12, 2018 Use PLAY NONE, put all channels volume to zero, and then do whatever you want, to restart music tracker use PLAY SIMPLE or PLAY FULL as you were using. But if he plays sound effects in the meantime, would that change any of the internal data structures of the music tracker and corrupt the song when it re-plays? Will the music tracker also know to re-set all PSG registers which could have changed in the meantime? I'm thinking on it, I know it will use a lot of precious 16-bit variables. It could be optional, for those who wish to give up those variables. Also, one thing that has to be considered is that it will eat precious game loop cycles because the music tracker will need to read and decode three more tracks from data, update their data structures, and update the second PSG registers. It is certainly possible, and perhaps even desirable, but it doesn't come for free. The ECS module does come with 2KB of RAM. I'm unsure if it is 16-bit RAM or 8-bit RAM. 8-bit RAM. -dZ. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 12, 2018 Author Share Posted February 12, 2018 But if he plays sound effects in the meantime, would that change any of the internal data structures of the music tracker and corrupt the song when it re-plays? Will the music tracker also know to re-set all PSG registers which could have changed in the meantime? A good point. The music tracker will re-use the channels immediately in the next state. Also the noise and mixer register. Only could fail if you use NO DRUMS then you should setup mixer/noise correctly. It could be optional, for those who wish to give up those variables. Also, one thing that has to be considered is that it will eat precious game loop cycles because the music tracker will need to read and decode three more tracks from data, update their data structures, and update the second PSG registers. It is certainly possible, and perhaps even desirable, but it doesn't come for free. That's right. 8-bit RAM. -dZ. Not yet a way to use this ECS capability. Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 12, 2018 Share Posted February 12, 2018 Not yet a way to use this ECS capability. PEEK and POKE work. Address range is $4040 - $47FF. And as others have mentioned, ECS RAM is 8-bit. So, if you're OK w/ using PEEK/POKE to access those data structures, you have an option. Here's my ECS tech-info summary from ages ago: http://spatula-city.org/~im14u2c/intv/tech/ecs.html Does it make sense to add a DPEEK and DPOKE that reads/writes 16-bit data across two 8 bit locations? (If reads use SDBD; MVI@ explicitly, that could be used for some interesting programming tricks even in 16-bit memory.) 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 12, 2018 Share Posted February 12, 2018 (Also, technically $4000 - $403F is available, but POKEs in that address range may write to STIC registers at $0000 - $003F, and a PEEK at $4021 could flip your video mode.) 1 Quote Link to comment Share on other sites More sharing options...
artrag Posted February 13, 2018 Share Posted February 13, 2018 About the 6 channel player, I've added a trick to duplicate the psg on the ecs on a different octave. Effortless, but still effective. You can listen it in the last deep zone build. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.