コード例 #1
0
static void jump_linenum (int linenum)
{
  FILE *original;
  int   finished;

  /* Not only does this verify whether the scanner finished,
     if it has finished, it additionally closes the stream. */
  finished = tokenizer_finished();
  /* We save this copy in case the scanner wasn't finished. */
  original = io_handle();

  /* Start a new scanner from the beginning of the file. */
  tokenizer_init(io_file());
  reset(T_ERROR);
  io_reset();

  /* Search for linenum. */
  find_linenum(linenum);

  /* If the search ended at EOF, linenum could not be found! */
  if (tokenizer_finished())
  {
    dprintf(
      "*warning: could not jump to `%d'\n",
      E_WARNING, linenum);
    /* Set back to original stream */
    io_set(io_file(), original);
    /* Prepare scanner to continue. */
    if (!finished)
    {
      reset(T_NUMBER);
      io_reset();
      io_next();
    }
  }
}
コード例 #2
0
ファイル: uzeboxCore.c プロジェクト: Bevinsky/uzebox-tactics
void SetRenderingParameters(u8 firstScanlineToRender, u8 scanlinesToRender){        
	render_lines_count_tmp=scanlinesToRender;
	first_render_line_tmp=firstScanlineToRender;
}


/*
 * I/O initialization table
 * The io_set macro is used to build an array of register,value pairs.
 * Using an array take less flash than discrete AVR instrustructions.
 */
#define io_set(a,b) ((_SFR_MEM_ADDR(a) & 0xff) + ((b)<<8))
#define set_io_end  0x0001

const u16 io_table[] PROGMEM ={
	io_set(TCCR1B,0x00),	//stop timers
	io_set(TCCR0B,0x00),
	io_set(DDRC,0xff), 		//video dac
	io_set(DDRB,0xff),		//h-sync for ad725
	io_set(DDRD,(1<<PD7)+(1<<PD4)), //audio-out + led 
	io_set(PORTD,(1<<PD4)+(1<<PD3)+(1<<PD2)), //turn on led & activate pull-ups for soft-power switches

	//setup port A for joypads
	io_set(DDRA,0b00001100), 	//set only control lines as outputs
	io_set(PORTA,0b11111011),  //activate pullups on the data lines

#if MIDI_IN == 1
	io_set(UCSR0B,(1<<RXEN0)), //set UART for MIDI in
	io_set(UCSR0C,(1<<UCSZ01)+(1<<UCSZ00)),
	io_set(UBRR0L,56), //31250 bauds (.5% error)
#endif
コード例 #3
0
ファイル: uzeboxCore.c プロジェクト: lawrencebrooks/uzebox
void SetRenderingParameters(u8 firstScanlineToRender, u8 scanlinesToRender){        
	render_lines_count=scanlinesToRender;
	first_render_line=firstScanlineToRender;
}


/*
 * I/O initialization table
 * The io_set macro is used to build an array of register,value pairs.
 * Using an array take less flash than discrete AVR instrustructions.
 */
#define io_set(a,b) ((_SFR_MEM_ADDR(a) & 0xff) + ((b)<<8))
#define set_io_end  0x0001

const u16 io_table[] PROGMEM ={
	io_set(TCCR1B,0x00),	//stop timers
	io_set(TCCR0B,0x00),

	io_set(SPL, UZEBOX_STACK_TOP & 0xFFU),
	io_set(SPH, UZEBOX_STACK_TOP >> 8),

	io_set(DDRC,0xff), 		//video dac

	io_set(DDRD,   (1 << PD7) | (1 << PD6) | (1 << PD4) | (1 << PD1)), // Audio-out, Chip Select, LED, UART TX
	io_set(PORTD,  (1 << PD6) | (1 << PD4) | (1 << PD5) | (1 << PD3) | (1 << PD2) | (1 << PD0)), // Set CS high, LED on, pull-up for all inputs (PD3, PD2 are buttons)

	//setup port A for joypads

	io_set(DDRA,   0x0C), // Set only control lines (CLK, Latch) as outputs
	io_set(PORTA,  0xFB), // Activate pullups on the data lines and unused pins
コード例 #4
0
ファイル: route_atob.c プロジェクト: deepfield/MRT
void
main (int argc, char *argv[])
{
    int c;
    extern char *optarg;	/* getopt stuff */
    extern int optind;		/* getopt stuff */
    char *usage =
    "Usage: route_atob [-i ascii_data_file] [-(o|w) binary_out_file]\n";
    char *filename = "stdin";
    char *ofile = "stdout";
    char *wfile = NULL;
    int errors = 0;
    io_t *IO;
    trace_t *default_trace;
    FILE *fd;

    default_trace = New_Trace ();
    IO = New_IO (default_trace);

    while ((c = getopt (argc, argv, "i:f:o:w:v")) != -1)
	switch (c) {
	case 'o':
	    ofile = (char *) (optarg);
	    break;
	case 'w':
	    wfile = (char *) (optarg);
	    break;
	case 'i':
	case 'f':
	    filename = (char *) optarg;
	    break;
	case 'v':
	    set_trace (default_trace, TRACE_FLAGS, TR_ALL,
		       TRACE_LOGFILE, "stdout", NULL);
	    break;
	default:
	    errors++;
	}

    init_mrt (default_trace);

    if (ofile) {
	if (io_set (IO, IO_OUTFILE, ofile, NULL) < 0) {
	    printf ("Error setting outfile: %s (%s)\n", ofile, strerror (errno));
	    errors++;
	}
    }
    if (wfile) {
	if (io_set (IO, IO_OUTMSGQ, wfile, NULL) < 0) {
	    printf ("Error setting output: %s (%s)\n", wfile, strerror (errno));
	    errors++;
	}
    }
    if (errors) {
	fprintf (stderr, usage);
	printf ("\nMRT version (%s) compiled on %s\n\n",
		MRT_VERSION, __DATE__);
	exit (0);
    }

    if (!strcasecmp (filename, "stdin"))
	fd = stdin;
    else
	fd = fopen (filename, "r");

    if (fd == NULL) {
	perror (filename);
	exit (1);
    }
    read_ascii (fd, IO);
    exit (0);
}
コード例 #5
0
ファイル: test.c プロジェクト: WodkaRHR/Violet_Sources
void trainerschool_test_init_components(){
    generic_callback1();
    if(!fading_is_active()){
        //init gfx and stuff
        
        big_callback_delete_all();
        oam_reset();
        oam_palette_allocation_reset();
        bg_reset(0);
        bg_setup(0, trainerschool_test_bg_configs, 3);
        
        bg_sync_display_and_show(0);
        bg_sync_display_and_show(1);
        bg_sync_display_and_show(2);
        bg_display_sync();
        bg_virtual_map_displace(0, 0, 0);
        bg_virtual_set_displace(0, 0, 0);
        bg_virtual_map_displace(1, 0, 0);
        bg_virtual_set_displace(1, 0, 0);
        bg_virtual_map_displace(2, 0, 0);
        bg_virtual_set_displace(2, 0, 0);
        io_set(0x10, 0);
        io_set(0x12, 4);
        io_set(0x14, 0);
        io_set(0x16, 0);
        io_set(0x18, 0);
        io_set(0x1A, 0);
        
        void *bg0map = malloc_and_clear(0x800);
        void *bg1map = malloc_and_clear(0x800);
        void *bg2map = malloc_and_clear(0x800);
        
        bg_set_tilemap(0, bg0map);
        bg_set_tilemap(1, bg1map);
        bg_set_tilemap(2, bg2map);
        
        lz77uncompwram(gfx_trainerschool_paperMap, bg2map);
        lz77uncompvram(gfx_trainerschool_paperTiles, (void*) 0x06000000);
        lz77uncompvram(gfx_trainerschool_page_0Tiles, (void*) 0x06004000);
        bg_copy_vram(0, bg0map, 0x800, 0, 2);
        bg_copy_vram(1, bg1map, 0x800, 0, 2);
        bg_copy_vram(2, bg2map, 0x800, 0, 2);
        pal_decompress(gfx_trainerschool_paperPal, 0, 32);
        u8 pal_id = oam_allocate_palette(0xA0E0);
        pal_decompress(gfx_trainerschool_correctPal, (u16)(256 + pal_id * 16), 32);
        pal_set_all_to_black(); //we avoid the 1frame show of a pal
        

        tbox_sync_with_virtual_bg_and_init_all(trainerschool_test_tboxes);
        trainerschool_test_load_question();
        
        oam_load_graphic(&trainerschool_test_graphic_correct);
        oam_load_graphic(&trainerschool_test_graphic_wrong);
        
        fadescreen_all(0, 0);
        callback1_set(trainerschool_test_idle);
        vblank_handler_set(generic_vblank_handler);

        bg_virtual_sync(0);
        bg_virtual_sync(1);
        bg_virtual_sync(2);
    }
}