]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
change message buffer initialization
authorLeo C <erbl259-lmu@yahoo.de>
Fri, 5 Jun 2015 06:46:35 +0000 (08:46 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Fri, 5 Jun 2015 06:46:35 +0000 (08:46 +0200)
avr/z180-serv.c
z180/config.inc
z180/init.180

index 929cd97148472d060afc2675f7bcdc4ae6bbf602..b5d8140dcee1ab3f327dd54e6d06bce83c11d35e 100644 (file)
@@ -581,35 +581,38 @@ int msg_handling(int state)
                pending = (Stat & S_MSG_PENDING) != 0;
                Stat &= ~S_MSG_PENDING;
        }
-/*
- * TODO: if pending but no message chr --> special condition. ie init,...
- */
 
        if (pending) {
-               switch (state) {
-               case 0:                 /* need init */
+               uint8_t init_request;
+               z80_bus_cmd(Request);
+               init_request = z80_read(0x43);
+               z80_bus_cmd(Release);
+               if ( init_request != 0) {
                        /* Get address of fifo_list */
+                       uint32_t fifo_addr = 0;
                        z80_bus_cmd(Request);
                        uint32_t fifo_list = z80_read(0x40) +
-                               ((uint16_t) z80_read(0x41) << 8) +
-                               ((uint32_t) z80_read(0x42) << 16);
-                       z80_bus_cmd(Release);
+                                               ((uint16_t) z80_read(0x41) << 8) +
+                                               ((uint32_t) z80_read(0x42) << 16);
                        if (fifo_list != 0) {
                                /* Get address of fifo 0 */
-                               z80_bus_cmd(Request);
-                               uint32_t fifo_addr = z80_read(fifo_list) +
-                                       ((uint16_t) z80_read(fifo_list+1) << 8) +
-                                       ((uint32_t) z80_read(fifo_list+2) << 16);
-                               z80_bus_cmd(Release);
-                               if (fifo_addr != 0) {
-                                       z80_memfifo_init(fifo_msgin, fifo_addr);
-                                       state = 1;
-                               }
+                               fifo_addr = z80_read(fifo_list) +
+                                                       ((uint16_t) z80_read(fifo_list+1) << 8);
+                                                       /* TODO: log to phys addr translation
+                                                       ((uint32_t) z80_read(fifo_list+2) << 16);
+                                                       */
                        }
-                       break;
-               case 1:                 /* awaiting messages */
+                       z80_write(0x43, 0);
+                       z80_bus_cmd(Release);
+
+                       if (fifo_addr != 0) {
+                               z80_memfifo_init(fifo_msgin, fifo_addr);
+                               state = 1;
+                       } else
+                               state = 0;
+
+               } else {
                        check_msg_fifo();
-                       break;
                }
        }
 
@@ -629,9 +632,7 @@ void setup_z180_serv(void)
 void restart_z180_serv(void)
 {
        z80_bus_cmd(Request);
-       z80_write(0x40, 0);
-       z80_write(0x41, 0);
-       z80_write(0x42, 0);
+       z80_memset(0x40, 0, 4);
        z80_bus_cmd(Release);
 
        for (int i = 0; i < NUM_FIFOS; i++)
index b5a53192f9adc47e44ddfb47d43a05e5750c7e8d..ffab6e6c94040daebc742ae4d87832f1fa2d54d2 100644 (file)
@@ -170,7 +170,8 @@ mkbuf       macro   id,name,size
     name&.mask equ ;wrong size error\r
   else\r
     db id\r
-    ds 3\r
+    db size-1\r
+    ds 2\r
     name:: ds size\r
     name&.mask equ low (size-1)\r
     if size ne 0\r
index d56975e7ae3b5021dec463d303853361961ae7e6..4c7bd77e0a7233f5d579b41fdd9034c477b05a88 100644 (file)
@@ -233,7 +233,6 @@ syscbr:     db      0
 buf.init:\r
        ld      (ix+o.in_idx),0\r
        ld      (ix+o.out_idx),0\r
-       ld      (ix+o.mask),a\r
 \r
        ld      a,(ix+o.id)\r
        cp      4\r
@@ -247,10 +246,8 @@ buf.init:
        ld      d,0\r
        add     hl,de\r
        add     hl,de\r
-       add     hl,de\r
        push    ix\r
        pop     de\r
-; TODO: address translation\r
        ld      (hl),e\r
        inc     hl\r
        ld      (hl),d\r
@@ -270,7 +267,6 @@ bufi_ex:
 fifo_list:\r
        rept 4\r
         dw     0\r
-        db     0\r
        endm\r
 \r
 ;----------------------------------------------------------------------\r