]> git.sur5r.net Git - cc65/commitdiff
New randomize() function for nearly all platforms
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 5 Nov 2002 10:48:20 +0000 (10:48 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 5 Nov 2002 10:48:20 +0000 (10:48 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1487 b7a2c559-68d2-44c3-8de9-860c34a00d81

19 files changed:
libsrc/c128/Makefile
libsrc/c128/c128.inc
libsrc/c128/randomize.s [new file with mode: 0644]
libsrc/c64/Makefile
libsrc/c64/c64.inc
libsrc/c64/randomize.s [new file with mode: 0644]
libsrc/cbm510/Makefile
libsrc/cbm510/randomize.s [new file with mode: 0644]
libsrc/cbm610/Makefile
libsrc/cbm610/randomize.s [new file with mode: 0644]
libsrc/pet/Makefile
libsrc/pet/pet.inc
libsrc/pet/randomize.s [new file with mode: 0644]
libsrc/plus4/Makefile
libsrc/plus4/plus4.inc
libsrc/plus4/randomize.s [new file with mode: 0644]
libsrc/vic20/Makefile
libsrc/vic20/randomize.s [new file with mode: 0644]
libsrc/vic20/vic20.inc

index 4096855b5032f67d76ec2e630b51e50b8c75d62e..bbf6e953ada330ec960051250517047281ed9921 100644 (file)
@@ -21,6 +21,7 @@ OBJS =        _scrsize.o      \
        cputc.o         \
        kbhit.o         \
        mouse.o         \
+        randomize.o     \
        readjoy.o       \
        rs232.o         \
        tgi_mode_table.o\
index 8e4415e70792f6171438c0cda40e27c7d78307b4..87d88f19e6309fe80ab05f0241bcae4a70291af2 100644 (file)
@@ -8,6 +8,7 @@
 
 ST                     = $90           ; IEC status byte
 
+TIME            = $A0           ; 60HZ clock
 FNAM_LEN               = $B7           ; Length of filename
 SECADR                 = $B9           ; Secondary address
 DEVNUM                 = $BA           ; Device number
diff --git a/libsrc/c128/randomize.s b/libsrc/c128/randomize.s
new file mode 100644 (file)
index 0000000..e4b731e
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+
+       .include        "c128.inc"
+
+_randomize:
+        ldx     VIC_HLINE       ; Use VIC rasterline as high byte
+        lda     TIME            ; Use 60HZ clock as low byte
+        jmp     _srand          ; Initialize generator
+
index 636f7abfd2504316678cadeb9c2871f5718212fc..f35520ecfb2ff29a7828d5d5d45d080560ec9d79 100644 (file)
@@ -24,6 +24,7 @@ OBJS =        _scrsize.o              \
                cputc.o                 \
                kbhit.o                 \
                mouse.o                 \
+        randomize.o             \
                readjoy.o               \
                rs232.o                 \
         tgi_mode_table.o       \
@@ -43,4 +44,4 @@ all:  $(OBJS) $(TGIS)
 
 clean:
        @rm -f $(OBJS) $(TGIS:.tgi=.o)
-
+                                 
index 315aaf69865315a6b0008d174586e859d89b4452..0d6b1c821a6146d87d69f04e286a28da20c02cee 100644 (file)
@@ -8,6 +8,7 @@
 
 ST             = $90           ; IEC status byte
 
+TIME            = $A0           ; 60 HZ clock
 FNAM_LEN       = $B7           ; Length of filename
 SECADR         = $B9           ; Secondary address
 DEVNUM         = $BA           ; Device number
diff --git a/libsrc/c64/randomize.s b/libsrc/c64/randomize.s
new file mode 100644 (file)
index 0000000..c46764b
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+
+       .include        "c64.inc"
+
+_randomize:
+        ldx     VIC_HLINE       ; Use VIC rasterline as high byte
+        lda     TIME            ; Use 60HZ clock as low byte
+        jmp     _srand          ; Initialize generator
+
index 729e9bce4eacd40e1aca4622c87e5a7c04964b59..e7e1b8494441cee07c14bce48dff21399f0a9e21 100644 (file)
@@ -28,6 +28,7 @@ OBJS =        _scrsize.o      \
        mouse.o         \
        peeksys.o       \
        pokesys.o       \
+        randomize.o     \
        readjoy.o       \
        rs232.o         \
        tgi_mode_table.o
diff --git a/libsrc/cbm510/randomize.s b/libsrc/cbm510/randomize.s
new file mode 100644 (file)
index 0000000..f32bb37
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+        .importzp       time
+
+_randomize:
+        ldx     time            ; Use 50/60HZ clock
+        lda     time+1
+        jmp     _srand          ; Initialize generator
+
index d6575c5ef87dc47aed1e0e92d8d9ec0db0aa2069..4967dd7bb27fae11f3d824727a1a2e6ab7c6ac0c 100644 (file)
@@ -27,6 +27,7 @@ OBJS =        _scrsize.o      \
        kudtim.o        \
        peeksys.o       \
        pokesys.o       \
+        randomize.o     \
        rs232.o
 
 all:   $(OBJS)
diff --git a/libsrc/cbm610/randomize.s b/libsrc/cbm610/randomize.s
new file mode 100644 (file)
index 0000000..f32bb37
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+        .importzp       time
+
+_randomize:
+        ldx     time            ; Use 50/60HZ clock
+        lda     time+1
+        jmp     _srand          ; Initialize generator
+
index 49a578629b634b262df23cf904632dbefe58052c..4bc6c22128bdda121ff23da6859b6e4a493c85af 100644 (file)
@@ -19,7 +19,8 @@ OBJS =        _scrsize.o      \
        conio.o         \
        cputc.o         \
        crt0.o          \
-       kbhit.o
+       kbhit.o         \
+        randomize.o     
 
 all:   $(OBJS)
 
index 4dcb73947057a63f7e12650350a1128a8a39f973..e8305122217a5539e609263a8bbde453b272582b 100644 (file)
@@ -6,6 +6,7 @@
 ; ---------------------------------------------------------------------------
 ; Zero page, Commodore stuff
 
+TIME            = $8D           ; 60HZ clock
 MEMSIZE                = $34           ; Size of memory installed
 ST                     = $96           ; IEC status byte
 SECADR         = $D3           ; Secondary address
diff --git a/libsrc/pet/randomize.s b/libsrc/pet/randomize.s
new file mode 100644 (file)
index 0000000..aea26df
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+
+       .include        "pet.inc"
+
+_randomize:
+        ldx     TIME
+        lda     TIME+1          ; Use 60HZ clock
+        jmp     _srand          ; Initialize generator
+
index e7f6207207ea1c048a879479c8b03a3ed02d963c..2c431741ecda1fc60469318900eab165ad760a5d 100644 (file)
@@ -20,6 +20,7 @@ OBJS =        _scrsize.o      \
        cputc.o         \
        crt0.o          \
        kbhit.o         \
+        randomize.o     \
        readjoy.o       \
        tgi_mode_table.o
 
index 5b8ab265ba16d81bc7707b232d997fb8fdd990ca..259fc75400b1c55beb278bd2c1178f7d7b335bc6 100644 (file)
@@ -8,6 +8,7 @@
 
 ST             = $90           ; IEC status byte
 
+TIME            = $A3           ; 60HZ clock
 FNAM_LEN               = $AB           ; Length of filename
 SECADR         = $AD           ; Secondary address
 DEVNUM         = $AE           ; Device number
diff --git a/libsrc/plus4/randomize.s b/libsrc/plus4/randomize.s
new file mode 100644 (file)
index 0000000..aae7ef5
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+
+       .include        "plus4.inc"
+
+_randomize:
+        ldx     TED_VLINELO     ; Use TED rasterline as high byte
+        lda     TIME            ; Use 60HZ clock as low byte
+        jmp     _srand          ; Initialize generator
+
index 30c868e88d25c77b873064a018043566e3242596..49f9755572ca2f4eb9d22bdb3076f48e4f950986 100644 (file)
@@ -20,6 +20,7 @@ OBJS =        _scrsize.o      \
        conio.o         \
        cputc.o         \
        kbhit.o         \
+        randomize.o     \
        readjoy.o       \
        write.o
 
diff --git a/libsrc/vic20/randomize.s b/libsrc/vic20/randomize.s
new file mode 100644 (file)
index 0000000..bbf9733
--- /dev/null
@@ -0,0 +1,21 @@
+;
+; Ullrich von Bassewitz, 05.11.2002
+;
+; void randomize (void);
+; /* Initialize the random number generator */
+;
+
+       .export         _randomize
+       .import         _srand
+
+       .include        "vic20.inc"
+
+_randomize:
+        lda     VIC_LINES       ; Get overflow bit
+        asl     a               ; Shift bit 7 into carry
+        lda     VIC_HLINE       ; Get bit 1-8 of rasterline 
+        rol     a               ; Use bit 0-7
+        tax                     ; Use VIC rasterline as high byte
+        lda     TIME            ; Use 60HZ clock as low byte
+        jmp     _srand          ; Initialize generator
+
index 56bf0ec14dd75880bcc5ec4570d21b25554b5d86..c67be541e340686548c6f1779bb73793fa80e94f 100644 (file)
@@ -8,6 +8,7 @@
 
 ST             = $90           ; IEC status byte
 
+TIME            = $A0           ; 60HZ clock
 FNAM_LEN       = $B7           ; Length of filename
 SECADR         = $B9           ; Secondary address
 DEVNUM         = $BA           ; Device number
@@ -30,10 +31,10 @@ PALFLAG             = $2A6          ; $01 = PAL, $00 = NTSC
 ; Kernal routines
 
 ; Direct entries
-CLRSCR         = $E55F         
-KBDREAD                = $E5CF         
+CLRSCR         = $E55F
+KBDREAD                = $E5CF
 NAMED_OPEN     = $F495
-NAMED_CLOSE    = $F6DA         
+NAMED_CLOSE    = $F6DA
 PLOTCHAR       = $EAAA         ; Char in A, color in X
 
 ; ---------------------------------------------------------------------------
@@ -46,8 +47,10 @@ NMIVec               = $0318
 ; ---------------------------------------------------------------------------
 ; I/O: 6560 VIC
 
-VIC            = $9000
-VIC_COLOR      = $900F
+VIC            = $9000                               
+VIC_LINES       = $9003         ; Screen lines, bit 7 is bit 0 from VIC_HLINE
+VIC_HLINE       = $9004         ; Rasterline, bits 1-8
+VIC_COLOR      = $900F         ; Border and background color
 
 ; ---------------------------------------------------------------------------
 ; I/O: 6522 VIA1