]> git.sur5r.net Git - cc65/commitdiff
Added the hack for write() to make printf work
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 13 Sep 2001 16:01:32 +0000 (16:01 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 13 Sep 2001 16:01:32 +0000 (16:01 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@907 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/c128/Makefile
libsrc/c128/mouse.s
libsrc/c128/write.s [new file with mode: 0644]

index 05559bb3f221d9020ab6b5ca000bb5f7c22ea24f..e20a5d342981e745277932174dec32d3ff8a3467 100644 (file)
@@ -21,7 +21,8 @@ OBJS =        _scrsize.o      \
        cputc.o         \
        kbhit.o         \
        mouse.o         \
-       readjoy.o                
+       readjoy.o       \
+       write.o
 
 all:           $(OBJS)
 
index 493d297fc4d3fe5ce6f47a2fd10875cd7a412d92..50ebc54feeb9e92990b8d23b7b96207f575be42b 100644 (file)
@@ -13,7 +13,7 @@
        .condes         MouseIRQ, 2
 
        .import         _readjoy
-               .import         popa, popax, addysp1
+               .import         popax, addysp1
        .importzp       ptr1, sp, sreg
 
        .include        "c128.inc"
@@ -36,14 +36,10 @@ XCORR               = SPRITE_WIDTH
 
 ; --------------------------------------------------------------------------
 ;
-; unsigned char __fastcall__ mouse_init (unsigned char port,
-;                                       unsigned char type);
+; unsigned char __fastcall__ mouse_init (unsigned char type);
 ;
 
 .proc  _mouse_init
-
-       jsr     popa                    ; Ignore type and port
-
                lda     Initialized             ; Already initialized?
                bne     AlreadyInitialized      ; Jump if yes
 
@@ -155,7 +151,7 @@ AlreadyInitialized:
                lda     VIC_SPR_ENA             ; Get sprite enable register
        ora     #$01                    ; Enable sprite #0
        sta     VIC_SPR_ENA             ; Write back
-       cli                             ; Enable interrupts
+       cli                             ; Enable interrupts
 
 @L1:   rts
 
@@ -320,7 +316,7 @@ AlreadyInitialized:
 ; --------------------------------------------------------------------------
 ;
 ; Mouse interrupt handler
-;       
+;
 
 IRQDone:rts
 
diff --git a/libsrc/c128/write.s b/libsrc/c128/write.s
new file mode 100644 (file)
index 0000000..9a574f3
--- /dev/null
@@ -0,0 +1,47 @@
+;
+; Ullrich von Bassewitz, 30.05.1998
+;
+; int write (int fd, const void* buf, int count);
+;
+; THIS IS A HACK!
+;
+
+       .export         _write
+       .import         popax
+       .importzp       ptr1, ptr2, ptr3
+
+       .include        "../cbm/cbm.inc"
+
+_write:        jsr     popax           ; get count
+               sta     ptr2
+       stx     ptr2+1          ; save it for later
+       sta     ptr3
+       stx     ptr3+1          ; save for function result
+       jsr     popax           ; get buf
+       sta     ptr1
+       stx     ptr1+1
+       jsr     popax           ; get fd and discard it
+
+L1:    lda     ptr2
+       ora     ptr2+1          ; count zero?
+       beq     L9
+       ldy     #0
+       lda     (ptr1),y
+       jsr     BSOUT
+       inc     ptr1
+       bne     L2
+       inc     ptr1+1
+L2:    lda     ptr2
+       bne     L3
+       dec     ptr2
+       dec     ptr2+1
+       jmp     L1
+L3:    dec     ptr2
+       jmp     L1
+
+; No error, return count
+
+L9:    lda     ptr3
+       ldx     ptr3+1
+       rts
+