2018-11-10 22:41:05 +00:00
|
|
|
*
|
|
|
|
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
|
|
|
|
* *
|
|
|
|
* ARRAYS.MAC *
|
|
|
|
* *
|
|
|
|
* AUTHOR: NATHAN RIGGS *
|
|
|
|
* CONTACT: NATHAN.RIGGS@ *
|
|
|
|
* OUTLOOK.COM *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* VERSION: 0.2.0 *
|
|
|
|
* DATE: 10-DEC-2018 *
|
2018-11-10 22:41:05 +00:00
|
|
|
* ASSEMBLER: MERLIN 8 PRO *
|
2018-12-12 19:29:06 +00:00
|
|
|
* LICENSE: APACHE 2.0 *
|
|
|
|
* OS: DOS 3.3 *
|
2018-11-10 22:41:05 +00:00
|
|
|
* *
|
|
|
|
*------------------------------*
|
|
|
|
* *
|
|
|
|
* THIS IS A MACRO LIBRARY FOR *
|
|
|
|
* THE 8BIT ARRAY LIBRARIES, *
|
|
|
|
* ARRAYS81.LIB & ARRAYS82.LIB. *
|
|
|
|
* THESE ARE 8BIT 1D AND 2D *
|
|
|
|
* ARRAY LIBS, RESPECTIVELY. *
|
|
|
|
* *
|
|
|
|
*------------------------------*
|
|
|
|
* *
|
|
|
|
* LIST OF MACROS *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* DIM81: DIM 1D, 8BIT ARRAY *
|
|
|
|
* GET81: GET ELEMENT IN 8BIT, *
|
|
|
|
* 1D ARRAY. *
|
|
|
|
* PUT81: PUT VALUE INTO ARRAY *
|
|
|
|
* AT SPECIFIED INDEX *
|
|
|
|
* DIM82: DIM A 2D, 8BIT ARRAY *
|
|
|
|
* GET82: GET ELEMENT IN 8BIT, *
|
|
|
|
* 2D ARRAY *
|
|
|
|
* PUT82: PUT VALUE INTO ARRAY *
|
|
|
|
* AT SPECIFIED INDEX *
|
2018-11-10 22:41:05 +00:00
|
|
|
* *
|
|
|
|
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* DIM81 : INIT 1D, 8BIT ARRAY *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* INITS A 1-DIMENSIONAL ARRAY *
|
|
|
|
* BY CLEARING MEMORY IT WILL *
|
|
|
|
* SPAN ACROSS AND PUTTING THE *
|
|
|
|
* INDEXING INFORMATION AS THE *
|
|
|
|
* ARRAY HEADER (0 = ARRAY *
|
|
|
|
* LENGTH, 1 = ELEMEN LENGTH). *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = ARRAY ADDRESS *
|
|
|
|
* ]2 = ARRAY BYTE LENGTH *
|
|
|
|
* ]3 = ELEMENT BYTE LENGTH *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* DIM81 $300;#10;#2 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-12 19:29:06 +00:00
|
|
|
DIM81 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1 ; ARRAY ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA ]2 ; ARRAY LENGTH
|
|
|
|
PHA
|
|
|
|
LDA ]3 ; ELEMENT LENGTH
|
|
|
|
PHA
|
2018-12-12 19:29:06 +00:00
|
|
|
JSR ADIM81
|
2018-11-10 22:41:05 +00:00
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* GET81 : GET ARRAY ELEMENT *
|
2018-11-10 22:41:05 +00:00
|
|
|
* FROM 1D, 8BIT ARRAY *
|
|
|
|
*- -*
|
2018-12-12 19:29:06 +00:00
|
|
|
* GETS THE VALUE HELD IN AN *
|
|
|
|
* ARRAY AT THE SPECIFIED *
|
|
|
|
* ELEMENT. THAT VALUE IS PUT *
|
|
|
|
* INTO [RETURN], WITH THE *
|
|
|
|
* LENGTH IN [RETLEN]. THE *
|
|
|
|
* ELEMENT ADDRESS IS PUT IN *
|
|
|
|
* .Y (LOW) AND .X (HIGH). *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = ARRAY ADDRESS *
|
|
|
|
* ]2 = ELEMENT INDEX *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* GET81 $300;#5 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-12 19:29:06 +00:00
|
|
|
GET81 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1 ; ARRAY ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA ]2 ; ELEM INDEX
|
|
|
|
PHA
|
|
|
|
JSR AGET81
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* PUT81 : PUT ARRAY ELEMENT *
|
2018-11-10 22:41:05 +00:00
|
|
|
* IN 1D, 8BIT ARRAY *
|
|
|
|
*- -*
|
|
|
|
* COPIES DATA FROM ONE MEMORY *
|
2018-12-12 19:29:06 +00:00
|
|
|
* LOCATION (]1) AND PUTS IT *
|
|
|
|
* IN THE SPECIFIED ARRAY (]2) *
|
|
|
|
* AT THE SPECIFIED INDEX (]3). *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = SOURCE ADDRESS *
|
|
|
|
* ]2 = ARRAY ADDRESS *
|
|
|
|
* ]3 = ELEMENT INDEX *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* PUT81 $300;$3A0;#5 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-12 19:29:06 +00:00
|
|
|
PUT81 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1
|
|
|
|
PHA ; SRC ADDR
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA #>]2 ; DEST ARRAY
|
|
|
|
PHA
|
|
|
|
LDA #<]2
|
|
|
|
PHA
|
|
|
|
LDA ]3 ; DEST INDEX
|
|
|
|
PHA
|
|
|
|
JSR APUT81
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* DIM82 : INIT 12, 8BIT ARRAY *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* INITS AN 8BIT 2D ARRAY AT *
|
|
|
|
* SPECIFIED LOCATION WITH THE *
|
|
|
|
* DIMENSIONS OF X,Y. ARRAY *
|
|
|
|
* BEGINS WITH A 4 BYTE HEADER *
|
|
|
|
* WITH THE ARRAY LENGTH, X *
|
|
|
|
* DIM, Y DIM, AND ELEM LENGTH. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = ARRAY ADDRESS *
|
|
|
|
* ]2 = X DIMENSION *
|
|
|
|
* ]3 = Y DIMENSION *
|
|
|
|
* ]4 = ELEMENT SIZE *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* DIM82 $300;#4;#4;#1 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-12 19:29:06 +00:00
|
|
|
DIM82 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1 ; ARRAY ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA ]2 ; X DIM
|
|
|
|
PHA
|
|
|
|
LDA ]3 ; Y DIM
|
|
|
|
PHA
|
|
|
|
LDA ]4 ; ELEMENT LENGTH
|
|
|
|
PHA
|
2018-12-12 19:29:06 +00:00
|
|
|
JSR ADIM82
|
2018-11-10 22:41:05 +00:00
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* GET82 : GET ARRAY ELEMENT *
|
2018-11-10 22:41:05 +00:00
|
|
|
* FROM 2D, 8BIT ARRAY *
|
|
|
|
*- -*
|
|
|
|
* RETURNS THE MEMORY LOCATION *
|
|
|
|
* OF AN X,Y INDEX IN THE ARRAY *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = ARRAY ADDRESS *
|
|
|
|
* ]2 = X INDEX *
|
|
|
|
* ]3 = Y INDEX *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* GET82 $300;#2;#3 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2019-01-07 04:08:25 +00:00
|
|
|
GET82 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1 ; ARRAY ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA ]2 ; X INDEX
|
|
|
|
PHA
|
|
|
|
LDA ]3 ; Y INDEX
|
|
|
|
PHA
|
|
|
|
JSR AGET82
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-12 19:29:06 +00:00
|
|
|
* PUT82 : PUT ARRAY ELEMENT *
|
|
|
|
* IN 2D, 8BIT ARRAY *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* COPIES DATA FROM SOURCE LOC *
|
|
|
|
* TO THE MEMLOC OF INDEX X,Y *
|
|
|
|
* IN THE SPECIFIED ARRAY. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-12 19:29:06 +00:00
|
|
|
* ]1 = SOURCE ADDRESS *
|
|
|
|
* ]2 = DEST ARRAY ADDRESS *
|
|
|
|
* ]3 = ELEMENT X INDEX *
|
|
|
|
* ]4 = Y INDEX *
|
2018-11-10 22:41:05 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-12 19:29:06 +00:00
|
|
|
* PUT82 $300;$3A0;#2;#3 *
|
2018-11-10 22:41:05 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2019-01-07 04:08:25 +00:00
|
|
|
PUT82 MAC
|
2018-11-10 22:41:05 +00:00
|
|
|
LDA #>]1 ; SRC ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
LDA #>]2 ; ARRAY ADDR
|
|
|
|
PHA
|
|
|
|
LDA #<]2
|
|
|
|
PHA
|
|
|
|
LDA ]3 ; X INDEX
|
|
|
|
PHA
|
|
|
|
LDA ]4 ; Y INDEX
|
|
|
|
PHA
|
|
|
|
JSR APUT82
|
|
|
|
<<<
|
|
|
|
*
|