Previous 15994 Revisions Next

r5340 Monday 3rd August, 2009 at 10:40:15 UTC by Miodrag Milanović
[PK8000] Removing redundant code
[src/mess]mess.mak
[src/mess/drivers]pk8000.c

src/mess/mess.mak
r5339r5340
698698   $(MESS_MACHINE)/mikro80.o   \
699699   $(MESS_VIDEO)/mikro80.o      \
700700   $(MESS_DRIVERS)/pk8000.o   \
701   $(MAME_VIDEO)/pk8000.o      \
701702   $(MESS_DRIVERS)/pk8020.o   \
702703   $(MESS_MACHINE)/pk8020.o   \
703704   $(MESS_VIDEO)/pk8020.o      \
src/mess/drivers/pk8000.c
r5339r5340
1414#include "formats/fmsx_cas.h"
1515#include "sound/speaker.h"
1616#include "sound/wave.h"
17#include "includes/pk8000.h"
1718
18static UINT8 pk8000_text_start;
19static UINT8 pk8000_chargen_start;
20static UINT8 pk8000_video_start;
21static UINT8 pk8000_color_start;
22   
23static UINT8 pk8000_video_mode;
24static UINT8 pk8000_video_color;
25static UINT8 pk8000_color[32];
26static UINT8 pk8000_video_enable;
27
2819static UINT8 keyboard_line;
2920
3021static const device_config *cassette_device_image(running_machine *machine)
r5339r5340
150141   DEVCB_HANDLER(pk8000_84_portc_w)
151142};
152143
153static READ8_HANDLER(pk8000_video_color_r)
154{
155   return pk8000_video_color;
156}
157
158static WRITE8_HANDLER(pk8000_video_color_w)
159{
160   pk8000_video_color = data;
161}
162
163static READ8_HANDLER(pk8000_text_start_r)
164{
165   return pk8000_text_start;
166}
167static WRITE8_HANDLER(pk8000_text_start_w)
168{
169   pk8000_text_start = data;
170}
171static READ8_HANDLER(pk8000_chargen_start_r)
172{
173   return pk8000_chargen_start;
174}
175static WRITE8_HANDLER(pk8000_chargen_start_w)
176{
177   pk8000_chargen_start = data;
178}
179static READ8_HANDLER(pk8000_video_start_r)
180{   
181   return pk8000_video_start;
182}
183static WRITE8_HANDLER(pk8000_video_start_w)
184{
185   pk8000_video_start = data;
186}
187static READ8_HANDLER(pk8000_color_start_r)
188{
189   return pk8000_color_start;
190}
191static WRITE8_HANDLER(pk8000_color_start_w)
192{
193   pk8000_color_start = data;
194}
195
196static READ8_HANDLER(pk8000_color_r)
197{
198   return pk8000_color[offset];
199}
200static WRITE8_HANDLER(pk8000_color_w)
201{
202   pk8000_color[offset] = data;
203}   
204
205144static READ8_HANDLER(pk8000_joy_1_r)
206145{
207146   UINT8 retVal = (cassette_input(cassette_device_image(space->machine)) > 0.0038 ? 0x80 : 0);
r5339r5340
372311
373312static VIDEO_UPDATE( pk8000 )
374313{
375   int x,y,j,b;
376   UINT16 offset = (pk8000_video_mode & 0xc0) << 8;
377   rectangle my_rect;
378   my_rect.min_x = 0;
379   my_rect.max_x = 256+32-1;
380   my_rect.min_y = 0;
381   my_rect.max_y = 192+32-1;
382   
383   if (pk8000_video_enable) {
384      bitmap_fill(bitmap, &my_rect, (pk8000_video_color >> 4) & 0x0f);
385     
386      if (BIT(pk8000_video_mode,4)==0){   
387         // Text mode
388         if (BIT(pk8000_video_mode,5)==0){
389            // 32 columns
390            for (y = 0; y < 24; y++)
391            {
392               for (x = 0; x < 32; x++)
393               {
394                  UINT8 chr  = mess_ram[x +(y*32) + ((pk8000_text_start & 0x0f) << 10)+offset] ;
395                  UINT8 color= pk8000_color[chr>>3];
396                  for (j = 0; j < 8; j++) {
397                     UINT8 code = mess_ram[((chr<<3) + j) + ((pk8000_chargen_start & 0x0e) << 10)+offset];
398                     
399                     for (b = 0; b < 8; b++)
400                     {                       
401                        UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f);
402                        *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) =  col;
403                     }
404                  }
405               }
406            }
407         } else {
408            // 40 columns                 
409            for (y = 0; y < 24; y++)
410            {
411               for (x = 0; x < 42; x++)
412               {
413                  UINT8 chr = mess_ram[x +(y*64) + ((pk8000_text_start & 0x0e) << 10)+offset] ;
414                  for (j = 0; j < 8; j++) {
415                     UINT8 code = mess_ram[((chr<<3) + j) + ((pk8000_chargen_start  & 0x0e) << 10)+offset];
416                     for (b = 2; b < 8; b++)
417                     {                       
418                        UINT8 col = ((code >> b) & 0x01) ? (pk8000_video_color) & 0x0f : (pk8000_video_color>>4) & 0x0f;
419                        *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*6+(7-b)+16+8) =  col;
420                     }
421                  }
422               }
423            }
424         }
425      } else {
426         //Graphics
427         for (y = 0; y < 24; y++)
428         {
429            UINT16 off_color = (((~pk8000_color_start) & 0x08) << 10)+offset + ((y>>3)<<11);
430            UINT16 off_code  = (((~pk8000_video_start) & 0x08) << 10)+offset + ((y>>3)<<11);
431            for (x = 0; x < 32; x++)
432            {
433               UINT8 chr  = mess_ram[x +(y*32) + ((pk8000_chargen_start & 0x0e) << 10)+offset] ;
434               for (j = 0; j < 8; j++) {
435                  UINT8 color= mess_ram[((chr<<3) + j)+off_color];
436                  UINT8 code = mess_ram[((chr<<3) + j)+off_code];
437                 
438                  for (b = 0; b < 8; b++)
439                  {                       
440                     UINT8 col = (code >> b) & 0x01 ? (color & 0x0f) : ((color>>4) & 0x0f);                 
441                     *BITMAP_ADDR16(bitmap, (y*8)+j+16, x*8+(7-b)+16) =  col;
442                  }
443               }
444            }
445         }
446      }
447   } else {
448      // Disabled video
449      bitmap_fill(bitmap, &my_rect, 0);
450   }
451    return 0;
314return pk8000_video_update(screen, bitmap, cliprect, memory_region(screen->machine, "maincpu"));
452315}
453316
454static const rgb_t pk8000_palette[16] = {
455   MAKE_RGB(0x00, 0x00, 0x00), // 0
456   MAKE_RGB(0x00, 0x00, 0x00), // 1
457   MAKE_RGB(0x00, 0xc0, 0x00), // 2
458   MAKE_RGB(0x00, 0xff, 0x00), // 3 
459   MAKE_RGB(0x00, 0x00, 0xc0), // 4 
460   MAKE_RGB(0x00, 0x00, 0xff), // 5 
461   MAKE_RGB(0x00, 0xc0, 0xc0), // 6 
462   MAKE_RGB(0x00, 0xff, 0xff), // 7 
463   MAKE_RGB(0xc0, 0x00, 0x00), // 8 
464   MAKE_RGB(0xff, 0x00, 0x00), // 9 
465   MAKE_RGB(0xc0, 0xc0, 0x00), // A 
466   MAKE_RGB(0xff, 0xff, 0x00), // B 
467   MAKE_RGB(0xc0, 0x00, 0xc0), // C 
468   MAKE_RGB(0xff, 0x00, 0xff), // D 
469   MAKE_RGB(0xc0, 0xc0, 0xc0), // E 
470   MAKE_RGB(0xff, 0xff, 0xff),   // F 
471};
472
473PALETTE_INIT( pk8000 )
474{
475   palette_set_colors(machine, 0, pk8000_palette, ARRAY_LENGTH(pk8000_palette));
476}
477
478317/* Machine driver */
479318static const cassette_config pk8000_cassette_config =
480319{

Previous 15994 Revisions Next


© 1998-2018 The MESS Team